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
Скрипт который выводит видео в консоль. Ничего лишнего)

video-to-ascii Скрипт который выводит видео в консоль. Ничего лишнего) Требования Минимальное разрешение экрана: 1280x720 Видео в качестве 360p 10-45f

Daniil Pisarev 155 Nov 28, 2022
Automatic video generator for local news

Automatic video generator for local news

Gabriel Monteiro 2 Jan 11, 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
Youtube-dislikes-adder - Add dislikes to the description of your YouTube videos.

Add number of dislikes to the description of your YouTube videos. Number of dislikes are updated if you let this function as a bot.

fluks 1 Aug 23, 2022
Help for manipulating the plex-media-server transcode on the raspberry pi

raspi-plex-transcode Help for manipulating the plex-media-server transcode on the raspberry pi Ensure hardware decoding works and your firmware is up

10 Sep 29, 2022
A python program which converts images and video into excel spreadsheets.

image2excel A program which converts images and video into Excel spreadsheets. Usage examples can be found in examples Videos can take a long time to

Oscar Peace 2 Aug 09, 2021
Telegram Video Chat Video Streaming bot 🇱🇰

🧪 Get SESSION_NAME from below: Pyrogram 🎭 Preview ✨ Features Music & Video stream support MultiChat support Playlist & Queue support Skip, Pause, Re

DOOZY YEZ 5 Jun 26, 2022
A multithreaded view bot for YouTube

Simple program to increase YouTube views written in Python.

Monirul Shawon 906 Jan 09, 2023
Python based script to operate FFMPEG.

FMPConvert Python based script to operate FFMPEG. Ver 1.0 -- 2022.02.08 Feature ✅ Maximum compatibility: Third-party dependency libraries unused ✅ Che

cybern000b 1 Feb 28, 2022
Filtering user-generated video content(SberZvukTechDays)Filtering user-generated video content(SberZvukTechDays)

Filtering user-generated video content(SberZvukTechDays) Table of contents General info Team members Technologies Setup Result General info This is a

Roman 6 Apr 06, 2022
A platform which give you info about the newest video on a channel

youtube A platform which give you info about the newest video on a channel. This uses web scraping, a better implementation will be to use the API. BR

Custom components for Home Assistant 36 Sep 29, 2022
Play Video & Music on Telegram Group Video Chat

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

Jonathan 5 Dec 31, 2021
Create a Video Membership app using FastAPI & NoSQL

Video Membership Create a Video Membership app using FastAPI & NoSQL. In this series, we're going to explore building a membership application using F

Coding For Entrepreneurs 69 Dec 25, 2022
Code for the manim-generated scenes used in 3blue1brown videos

Code for the manim-generated scenes used in 3blue1brown videos

Grant Sanderson 4.1k Jan 09, 2023
Video-stream - A telegram video stream bot repo

This is a Telegram Video stream Bot. Binary Tech 💫 Features stream videos downl

silentz lk 1 Feb 02, 2022
Tweet stream in OBS browser source

OBS-Twitter-Stream OBSなどの配信ソフトのブラウザソースで特定のキーワードを含んだツイートを表示します 使い方 使い方については以下のwikiを御覧ください https://github.com/CubeZeero/OBS-Twitter-Stream/wiki ダウンロード W

Cube 23 Dec 18, 2022
goal: render videos on eu4's timeline function

Rendering Videos on the EU4 Time Line This repository contains code to create an eu4-savefile that plays back a video in question.

29 Dec 24, 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
Program for converting video to GIF

video-to-gif Program for converting video to GIF Install the lib: pip install moviepy Usage: Specify the path to the video file. clip = VideoFileClip(

Artem Mokin 0 Dec 13, 2021
plumi video sharing

December 2017 update We are moving tickets from the Plumi tracker (trac.plumi.org) here, for historical reasons. Plumi video sharing system Plumi is a

Plumi 111 Dec 15, 2022