29

GitHub - joelibaceta/video-to-ascii: It is a simple python package to play video...

 5 years ago
source link: https://github.com/joelibaceta/video-to-ascii
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

Logo

It's a simple python package to play videos in a terminal using ASCII characters.

PyPI version Maintainability contributions welcome HitCount

frames

Installation

pip install video-to-ascii

The installation should copy the main script to your PATH and making it available for general use.

How to use

Just run video-to-ascii your video path in your terminal

$ video-to-ascii -f myvideo.mp4

How it works

Every video is composed by a set of frames that are played at a certain frame rate.

frames

Since a terminal has a specific number of rows and columns, we have to resize our video to adjust to the terminal size limitations.

frames

To reach a correct visualization of an entire frame we need to adjust the frame height to match the terminal rows, avoiding using more characters than the number of terminal columns.

frames

When picking a character to represent a pixel we need to measure the relevance of that pixel's color in the frame, based on that we can then select the most appropriate character based on the intensity they represent.

frames

The reduced range of colors supported by the terminal is a problem we need to account for. Modern terminals support up to 256 colors, so we need to find the closest 8 bit color that matches the original pixel color, we call this set of 256 colors ANSI colors.

frames

Finally, when putting it all together, we will have an appropriate character for each pixel and a new color.

frames


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK