Play video in colorized ASCII art in console
The file asciify.py in this project is from this repository, credits to them. (I only added a little bit changes to it for this project)
I added example images & videos which are clips and screenshots from Watch_Dogs & Cyberpunk 2077. I don't own them
Windows: cls && python img2colorized_ascii.py
Linux: clear && python img2colorized_ascii.py
First, run python prerender.py
to pre-render frames. It will save them as json file. (The json file size might be a bit large!)
Then run python prerender_play.py
to play the "video"
See requirements.txt
Steps:
- Opens the video from given path
- Read frame
- Convert the image (cv2) to PIL image
- Resize the PIL image
- Mark down each pixel's color
- Turn the image to ASCII art
- Colorized the characters with color
- Print out the colorized ASCII image
- Clears previous output
- Read next frame
- Back to Step 3
This is because the amount of charater per line in console is somehow limited (If I understand correctly)
In my case it's 100 characters per line
I resize the frame's width and height in ratio.
For example, a 1920x1080 image will be resized to 100x56
- The height of each output frame is 56
- The speed might be slower since it does all the steps above in real time (If it's not pre-rendered)
- There should be some blinking between each frame
I might do these someday but not sure when :P