MCPcopy
hub / github.com/joelibaceta/video-to-ascii

github.com/joelibaceta/video-to-ascii @1.2.9 sqlite

repository ↗ · DeepWiki ↗ · release 1.2.9 ↗
29 symbols 76 edges 12 files 24 documented · 83%
README

Logo

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

Financial Contributors on Open Collective PyPI version Maintainability contributions welcome HitCount

Screenshot

Translations

Requirements

  • Python3
  • PortAudio (Only required for installation with audio support)
  • FFmpeg (Only required for installation with audio support)

Installation

Standard installation

$ pip3 install video-to-ascii

With audio support installation

$ pip3 install video-to-ascii --install-option="--with-audio"

How to use

Just run video-to-ascii in your terminal

$ video-to-ascii -f myvideo.mp4

Options

--strategy Allow to choose an strategy to render the output.

Render Strategies

-o --output Export the rendering output to a bash file to share with someone.

Exporting

-a --with-audio If an installation with audio support was made, you can use this option to play the audio track while rendering the video ascii characters.

How it works

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

Video 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.

Terminal

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.

Resizing

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 relative luminance in colorimetric spaces, using a simplify version of the luminosity function.

Green light contributes the most to the intensity perceived by humans, and blue light the least.

This function returns an integer in the range from 0 to 255, we assign a character according to density to show more colored surface for areas with more intense color (highest values).

CHARS_LIGHT     = [' ', ' ', '.', ':', '!', '+', '*', 'e', '$', '@', '8']
CHARS_COLOR     = ['.', '*', 'e', 's', '@']
CHARS_FILLED    = ['░', '▒', '▓', '█']

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 in 16 or 24 bit color, we call this set of 256 colors ANSI colors.

The Mapping of RGB and ANSI Colors

8 Bits Color Table

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

Frame Image by Characters

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute].

Or maybe just buy me a coffee.

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

Core symbols most depended-on inside this repo

install_package
called by 3
setup.py
play
called by 2
video_to_ascii/video_engine.py
brightness_to_ascii
called by 2
video_to_ascii/render_strategy/image_processor.py
rgb_to_brightness
called by 2
video_to_ascii/render_strategy/image_processor.py
convert_frame_pixels_to_ascii
called by 2
video_to_ascii/render_strategy/ascii_strategy.py
resize_frame
called by 2
video_to_ascii/render_strategy/ascii_strategy.py
set_strategy
called by 1
video_to_ascii/video_engine.py
load_video_from_file
called by 1
video_to_ascii/video_engine.py

Shape

Method 14
Function 9
Class 6

Languages

Python100%

Modules by API surface

video_to_ascii/render_strategy/ascii_strategy.py7 symbols
video_to_ascii/render_strategy/image_processor.py6 symbols
video_to_ascii/video_engine.py5 symbols
video_to_ascii/render_strategy/render_strategy.py2 symbols
video_to_ascii/render_strategy/ascii_color_strategy.py2 symbols
video_to_ascii/render_strategy/ascii_color_filled_strategy.py2 symbols
video_to_ascii/render_strategy/ascii_bw_strategy.py2 symbols
video_to_ascii/player.py1 symbols
video_to_ascii/cli.py1 symbols
setup.py1 symbols

For agents

$ claude mcp add video-to-ascii \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact