python 字符视频_一个简单的python包,可以使用ASCII字符在终端中播放视频

2023-05-16

logo.svg?sanitize=true

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

68747470733a2f2f62616467652e667572792e696f2f70792f766964656f2d746f2d61736369692e73766768747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f61356663646632623063616234313635346361332f6d61696e7461696e6162696c69747968747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e747269627574696f6e732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174687474703a2f2f686974732e6477796c2e696f2f6a6f656c696261636574612f68747470733a2f2f6769746875622e636f6d2f6a6f656c696261636574612f766964656f2d746f2d61736369692e737667

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

In your terminal just run video-to-ascii + your video path.

$ video-to-ascii myvideo.mp4

How it works

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

imgVideoFrames.png

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

imgTerminal.png

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.

imgFrameResize.png

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.

imgBrightnes.png

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.

imgPixelSection.png

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

imgPixelImage.png

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

python 字符视频_一个简单的python包,可以使用ASCII字符在终端中播放视频 的相关文章

随机推荐