It is a simple python package to play videos in the terminal using characters as pixels

Overview

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)
  • Linux or MacOS ... by now

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]

Comments
  • Non-ASCII character '\xf0'

    Non-ASCII character '\xf0'

    File "/usr/local/bin/video-to-ascii", line 8 SyntaxError: Non-ASCII character '\xf0' in file /usr/local/bin/video-to-ascii on line 8, but no encoding declared;

    bug solved 
    opened by msongz 15
  • Not Installable

    Not Installable

    pip3 install ./video-to-ascii Processing ./video-to-ascii Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-req-build-irufanr_/setup.py", line 17, in <module> install_package('opencv-python') File "/tmp/pip-req-build-irufanr_/setup.py", line 10, in install_package main.main(['install', package]) AttributeError: 'function' object has no attribute 'main' I get the same thing using pip3 install video-to-ascii I think there is an error in the code.

    bug 
    opened by ghost 9
  • time.clock() has been removed in Python3.8

    time.clock() has been removed in Python3.8

    Hi, I run this program to watch some video on macOS. But I encounter problem: AttributeError: module 'time' has no attribute 'clock'.

    After I search that, I know: time.clock() has been removed in Python3.8.

    I have checked the related line of file, and replace it with time.process_time(). Then it works well. Maybe need to use other API on other OS. https://github.com/joelibaceta/video-to-ascii/blob/5c812d5e7fd9466050dcdd6d4441ce077f2378d8/video_to_ascii/render_strategy/ascii_strategy.py#L120

    opened by YigaoFan 5
  • ZeroDivisionError

    ZeroDivisionError

    How to solve this Problem? i used pip not pip3 to install opencv-python and video-to-ascii because it is not work

    Traceback (most recent call last): File "/home/andre/anaconda3/bin/video-to-ascii", line 10, in sys.exit(main()) File "/home/andre/anaconda3/lib/python3.7/site-packages/video_to_ascii/cli.py", line 21, in main player.play(ARGS.file, strategy=ARGS.strategy, output=ARGS.output, play_audio=ARGS.with_audio) File "/home/andre/anaconda3/lib/python3.7/site-packages/video_to_ascii/player.py", line 23, in play engine.play(output) File "/home/andre/anaconda3/lib/python3.7/site-packages/video_to_ascii/video_engine.py", line 38, in play with_audio=self.with_audio) File "/home/andre/anaconda3/lib/python3.7/site-packages/video_to_ascii/render_strategy/ascii_strategy.py", line 113, in render time_delta = 1./fps ZeroDivisionError: float division by zero

    bug 
    opened by AndreLYL 5
  • Errors with included executable file

    Errors with included executable file

    Installing on macos Mojave using the system pip and python yields the following error on execution:

    ❯ video-to-ascii
    /usr/local/bin/video-to-ascii: line 3: import: command not found
    from: can't read /var/mail/video_to_ascii
    /usr/local/bin/video-to-ascii: line 6: syntax error near unexpected token `('
    /usr/local/bin/video-to-ascii: line 6: `CLI_DESC = ("It is a simple python package to play videos in the terminal"'
    

    On a closer look, it's because the file bin/video-to-ascii is missing the ! from the shebang line, which should read like so:

    #!/usr/bin/env python
    

    Furthermore, you'll also want to include a line like this:

    # coding=utf-8
    

    Otherwise, I get this error:

    258 ❯ video-to-ascii
      File "/usr/local/lib/python2.7/bin/video-to-ascii", line 9
    SyntaxError: Non-ASCII character '\xf0' in file /usr/local/lib/python2.7/bin/video-to-ascii on line 9, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
    
    bug solved 
    opened by tomplex 4
  •     error: option --with-audio not recognized

    error: option --with-audio not recognized

    D:>pip3 install video-to-ascii --install-option="--with-audio" c:\users\footb\appdata\local\programs\python\python38\lib\site-packages\pip_internal\commands\install.py:230: UserWarning: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option. cmdoptions.check_install_build_global(options) Collecting video-to-ascii Using cached video_to_ascii-1.2.9.tar.gz (6.1 kB) Collecting xtermcolor Using cached xtermcolor-1.3.tar.gz (3.8 kB) Collecting ffmpeg-python Using cached ffmpeg-python-0.2.0.tar.gz (21 kB) Collecting future Using cached future-0.18.2.tar.gz (829 kB) Skipping wheel build for video-to-ascii, due to binaries being disabled for it. Skipping wheel build for ffmpeg-python, due to binaries being disabled for it. Skipping wheel build for future, due to binaries being disabled for it. Skipping wheel build for xtermcolor, due to binaries being disabled for it. Installing collected packages: future, xtermcolor, ffmpeg-python, video-to-ascii Running setup.py install for future ... error ERROR: Command errored out with exit status 1: command: 'c:\users\footb\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\footb\AppData\Local\Temp\pip-install-t_3_1qvw\future_95a3c7a8272d4d5ebfe5d44600f86280\setup.py'"'"'; file='"'"'C:\Users\footb\AppData\Local\Temp\pip-install-t_3_1qvw\future_95a3c7a8272d4d5ebfe5d44600f86280\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\footb\AppData\Local\Temp\pip-record-cg0z8f53\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\footb\appdata\local\programs\python\python38\Include\future' --with-audio cwd: C:\Users\footb\AppData\Local\Temp\pip-install-t_3_1qvw\future_95a3c7a8272d4d5ebfe5d44600f86280
    Complete output (6 lines): usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help

    error: option --with-audio not recognized
    ----------------------------------------
    

    ERROR: Command errored out with exit status 1: 'c:\users\footb\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\footb\AppData\Local\Temp\pip-install-t_3_1qvw\future_95a3c7a8272d4d5ebfe5d44600f86280\setup.py'"'"'; file='"'"'C:\Users\footb\AppData\Local\Temp\pip-install-t_3_1qvw\future_95a3c7a8272d4d5ebfe5d44600f86280\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\footb\AppData\Local\Temp\pip-record-cg0z8f53\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\footb\appdata\local\programs\python\python38\Include\future' --with-audio Check the logs for full command output.

    opened by HunterG6700 3
  • ValueError: not enough values to unpack (expected 2, got 0)

    ValueError: not enough values to unpack (expected 2, got 0)

    I've pip installed opencv-python and video-to-ascii in my PC, which runs Windows 10, Chinese simplified version. However, I constantly encouter the ValueError when I try to run "video-to-ascii -f filepath" command in terminal. Following is a screenshot about my commands. image How can I solve this trackback? Thanks.

    opened by Alowree 3
  • I cant install: No module named 'pip._internal'

    I cant install: No module named 'pip._internal'

    pip3 install video-to-ascii --install-option="--with-audio" /usr/lib/python3/dist-packages/pip/commands/install.py:212: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options. cmdoptions.check_install_build_global(options) Collecting video-to-ascii Downloading https://files.pythonhosted.org/packages/69/76/421fff0085dda88307ddb8bf31f4c99de815e707aaca28dae4a44330555f/video_to_ascii-1.2.6.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-build-wb40_x50/video-to-ascii/setup.py", line 16, in install_package('opencv-python') File "/tmp/pip-build-wb40_x50/video-to-ascii/setup.py", line 8, in install_package from pip._internal import main as pip ModuleNotFoundError: No module named 'pip._internal'

    ----------------------------------------
    

    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-wb40_x50/video-to-ascii/

    opened by hectorprats 3
  • Fixed the typos and wrong links in the original README file and add translations in Traditional Chinese.

    Fixed the typos and wrong links in the original README file and add translations in Traditional Chinese.

    • Fixed the typos and wrong links in the original README file.
    • Add the translations section in each README file.
    • Move the README in different languages into the translations folder to keep the folder structure clear.
    hacktoberfest-accepted 
    opened by Hsins 2
  • Translate readme to main spoken languages

    Translate readme to main spoken languages

    Due to global reach of this project we need to translate our readme to main spoken languages as:

    • [x] spanish or
    • [x] chinese

    We suggest use the format readme_es.md for naming the translated file .

    hacktoberfest 
    opened by joelibaceta 2
  • Doesn't work python 3.8

    Doesn't work python 3.8

    I got 'AttributeError: module 'time' has no attribute 'clock''. A simple google search let me to believe the 'time.clock()' function has been removed and replace by another. https://stackoverflow.com/questions/58569361/attributeerror-module-time-has-no-attribute-clock-in-python-3-8

    opened by MatisseBE 2
  • Pyaudio replaced by sounddevice library to fix some errors

    Pyaudio replaced by sounddevice library to fix some errors

    Currently, the Pyaudio library is getting errors when executed by Python 3.10. Changing the library to sounddevice fix this and get a robuster way to work with the audio stream.

    opened by RadinhoDePilha 0
  • Cannot Use Audio

    Cannot Use Audio

    After Installing the package, When i want to see a video with audio (-a) it gives the error ModuleNotFoundError: No module named 'pyaudio'

    I installed the package:

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

    Used it :

    video-to-ascii -f rickroll.mp4 --strategy filled-ascii -a
    

    It gives error. I also ran it with no audio and it worked Screenshots Screenshot from 2022-06-22 13-37-03 Screenshot from 2022-06-22 13-37-06

    • OS: Ubuntu 20.04
    • Python version: 3.8
    opened by mehanalavimajd 1
  • Error: ALSA lib pcm.c:8545:(snd_pcm_recover) underrun occurred

    Error: ALSA lib pcm.c:8545:(snd_pcm_recover) underrun occurred

    Hello! "ALSA lib pcm.c:8545:(snd_pcm_recover) underrun occurred" error. It plays, but the sound is very laggy. Tried restarting pulseaudio but didn't help. I tried "aconnect -x", the sound became a little better (faster), but the same error also lags. The error occurs at the bottom of the video. Collected using a script, with audio support. Debian, bullseye.

    opened by Fexonchik5120 0
  • Fixed setup.py

    Fixed setup.py

    I was unable to install the package. I found that the setup.py has a mistake in it.

    I fixed it here, please approve this request at : https://github.com/joelibaceta/video-to-ascii/pull/80

    opened by D4RKH0R1Z0N 0
Releases(1.2.9)
Owner
Joel Ibaceta
Software Engineer, Fintech Expert, Technical Advisor, Digital Nomad, Open Source Contributor, Investor
Joel Ibaceta
It is a simple python package to play videos in the terminal using characters as pixels

It is a simple python package to play videos in the terminal using characters as pixels

Joel Ibaceta 1.4k Jan 07, 2023
video streaming userbot (vsu) based on pytgcalls for streaming video trought the telegram video chat group.

VIDEO STREAM USERBOT ✨ an another telegram userbot for streaming video trought the telegram video chat. Environmental Variables 📌 API_ID : Get this v

levina 6 Oct 17, 2021
Play Video & Music on Telegram Group Video Chat

🖤 DEMONGIRL 🖤 ʜᴇʟʟᴏ ❤️ 🇱🇰 Join us ᴠɪᴅᴇᴏ sᴛʀᴇᴀᴍ ɪs ᴀɴ ᴀᴅᴠᴀɴᴄᴇᴅ ᴛᴇʟᴇʀᴀᴍ ʙᴏᴛ ᴛʜᴀᴛ's ᴀʟʟᴏᴡ ʏᴏᴜ ᴛᴏ ᴘʟᴀʏ ᴠɪᴅᴇᴏ & ᴍᴜsɪᴄ ᴏɴ ᴛᴇʟᴇɢʀᴀᴍ ɢʀᴏᴜᴘ ᴠɪᴅᴇᴏ ᴄʜᴀᴛ 🧪 ɢ

Jonathan 5 Dec 31, 2021
Meteor scan - Scan through video for meteor

meteor_scan Scan through video for meteor Installation Install python packages b

2 Jun 04, 2022
Python package for Near Duplicate Video Detection (Perceptual Video Hashing) - Get a 64-bit comparable hash-value for any video.

The Python package for near duplicate video detection ⭐️ Introduction Videohash is a Python package for detecting near-duplicate videos (Perceptual Vi

Akash Mahanty 144 Dec 19, 2022
Video processing routines for SciPy

scikit-video Video Processing SciKit BETA Video processing algorithms, including I/O, quality metrics, temporal filtering, motion/object detection, mo

Alex Izvorski 119 Dec 27, 2022
A Telegram bot to convert videos into x265/x264 format via ffmpeg.

Video Encoder Bot A Telegram bot to convert videos into x265/x264 format via ffmpeg. Configuration Add values in environment variables or add them in

1 Mar 08, 2022
Splat a video into a mosaic by sampling a frame at regular intervals

Splat a video into a mosaic by sampling a frame at regular intervals. Useful for seeing the changes over time of an entire video or movie.

Ryan Fox 4 Oct 16, 2022
Adblocker for movie subtitles.

SubAdBlock Adblocker for movie subtitles. Usage Place "main.py" and "config.conf" in directory with subtitles and run "main.py". It will automatically

Marko Živić 1 Jan 09, 2022
Vigia-youtube - The YouTube Watch bot is able to monitor channels on Google's video platform

Vigia do YouTube O bot Vigia do YouTube é capaz de monitorar canais na plataform

Alessandro Feitosa Jr 10 Oct 03, 2022
Program to play videos with props in Apex Legends

R5Fresh A video player for the Apex Legends mod R5Reloaded

9 Nov 13, 2022
Examples of usage of GStreamer hlssink3 plugin.

Examples of usage of GStreamer hlssink3 plugin.

Rafael Carício 2 Aug 03, 2022
GStreamer Inspector GUI

gst-explorer GStreamer GUI Interface Tool GUI interface for inspecting GStreamer Plugins, Elements and Type Finders. Expects Python3 Qt, PyQt5 and GSt

Jetsonhacks 31 Nov 29, 2022
Telegram Music/ Video Streaming Bot Using Pytgcalls

Video Player 🔥 ᴢᴀɪᴅ ᴠᴄ ᴘʟᴀyᴇʀ ɪꜱ ᴀ ᴛᴇʟᴇɢʀᴀᴍ ᴘʀᴏᴊᴇᴄᴛ ʙᴀꜱᴇᴅ ᴏɴ ᴘʏʀᴏɢʀᴀᴍ ꜰᴏʀ ᴘʟᴀʏ ᴍᴜꜱɪᴄꜱ ɪɴ ᴠᴄ ᴄʜᴀᴛꜱ... 🅡🅔🅟🅞 🅢🅣🅐🅣🅢 ʀᴇQᴜɪʀᴇᴍᴇɴᴛꜱ 📝 FFmpeg NodeJ

16 Nov 30, 2022
Image and video quality assessment

CenseoQoE: 视觉感知画质评价框架 项目介绍 图像/视频在编解码、传输和显示等过程中难免引入不同类型/程度的失真导致图像质量下降。图像/视频质量评价(IVQA)的研究目标是希望模仿人类视觉感知系统, 通过算法评估图片/视频在终端用户的眼中画质主观体验的好坏,目前在视频编解码、画质增强、画质监。

Tencent 133 Dec 20, 2022
Rembg Video Virtual Green Screen Edition

Rembg Virtual Greenscreen Edition is a tool to create a green screen matte for videos

Tim Scarfe 217 Jan 06, 2023
Video-to-GIF-Converter - A small code snippet that can be used to convert any video to a gif

Video to GIF Converter Project Description: This is a small code snippet that ca

Hassan Shahzad 3 Jun 22, 2022
Python program - to extract slides from videos

Programa em Python - que fiz em algumas horas e que provavelmente tem bugs - para extrair slides de vídeos.

Natanael Antonioli 45 Nov 12, 2022
FLIR/DJI IR Camera Data Parser, Python Version

FLIR/DJI IR Camera Data Parser, Python Version Parser infrared camera data as NumPy data. Usage Clone this respository and cd thermal_parser. Run pip

14 Dec 23, 2022
Youtube as covert-channel - Control systems remotely and execute commands by uploading videos to Youtube

covert-tube A program to control systems remotely by uploading videos to Youtube using Python to create the videos and the listener, emulating some ma

Ricardo Ruiz 101 Nov 01, 2022