Skip to main content

It is a simple python package to play videos in the terminal

Project description

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

Screenshot

Translations

Requirements

  • Python3
  • PortAudio (Only required for installation with audio support)
  • FFmpeg (Only required for installation with audio support)
  • Linux or MacOS ... for now

Installation

From PyPI (Recommended)

Standard installation (without audio support):

$ pip install video-to-ascii

With audio support:

$ pip install video-to-ascii[audio]

Complete installation (with all optional dependencies):

$ pip install video-to-ascii[all]

🔄 Migration Guide

If you were using the old installation method with --install-option:

# ❌ Old way (no longer supported)
$ pip install video-to-ascii --install-option="--with-audio"

# ✅ New way  
$ pip install video-to-ascii[audio]

Note: The --install-option flag has been deprecated by pip and removed in pip 23.1+.

From Source

Clone the repository and install:

$ git clone https://github.com/joelibaceta/video-to-ascii.git
$ cd video-to-ascii
$ pip install .

Or with audio support:

$ pip install .[audio]

How to use

Just run video-to-ascii in your terminal

$ video-to-ascii -f myvideo.mp4

Options

--strategy Allow to choose a 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 simplified 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]

As Seen On

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

video_to_ascii-1.3.1.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

video_to_ascii-1.3.1-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file video_to_ascii-1.3.1.tar.gz.

File metadata

  • Download URL: video_to_ascii-1.3.1.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for video_to_ascii-1.3.1.tar.gz
Algorithm Hash digest
SHA256 aff3853908f512046d3ca68ae76fe3d0f56127e5bcab5564d188c523ded1684b
MD5 adfa88fe4b1a572f8e85891e34618ad7
BLAKE2b-256 f03d8d9cb4ccd5f153bdda361e1169c1024084a1cb916d8cd273f727dfbd5ff7

See more details on using hashes here.

File details

Details for the file video_to_ascii-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: video_to_ascii-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for video_to_ascii-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eb7de606f7acd330595fa320d24e4e6ddb2533043f2d0bdf267caf0495f1577b
MD5 5c2c0be61d00600e63d49e88456af872
BLAKE2b-256 77aff0da8ec950061a39b05ed7f994ac50b98deb05c850fd51a3e3a5cb7fadfd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page