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
Takes a video as an input and creates a video which is suitable to upload on Youtube Shorts and Tik Tok (1080x1920 resolution).

Shorts-Tik-Tok-Creator Takes a video as an input and creates a video which is suitable to upload on Youtube Shorts and Tik Tok (1080x1920 resolution).

Arber Hakaj 5 Nov 09, 2022
A simple Python Youtube Wachtime for YTbebot

Simple bot that was development in python 3.7, that automatically watch youtube videos. It can be used to give more views in your channel helping in the spread and increase the followers because your

Rian eka wiratma 1 Dec 05, 2021
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
Video Translation Into Text

2021/12/9 The project has been updated Added a home screen Just drag it onto the screen The final results \ 2021/12/9 项目已更新 添加了主界面 拖到即可 最后结果 \ Using t

10 Mar 12, 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
Repository to create Ascii art in CMD based on video file.

Made to take any file format, and transform it into ascii art, displayed as a video in the cmd. If the cmd formatting is wrong, try zooming a little and remember to make cmd fullscreen. I made my cmd

60 Dec 17, 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
iYTDL - Asynchronous Standalone Inline YouTube-DL Module

iYTDL Asynchronous Standalone Inline YouTube-DL Module ⬇️ Installing Install pip3 install iytdl Upgrade pip3 install -U iytdl ⭐️ Features Fully Asynch

iYTDL 46 Dec 24, 2022
I have baked a custom integration to control Eufy Security Cameras and access RTSP and P2P stream if possible.

I have baked a custom integration to control Eufy Security Cameras and access RTSP (real time streaming protocol) and P2P (peer to peer) stream if pos

Fuat Akgün 422 Jan 01, 2023
Add the dislike count back to my YouTube videos via a comment containing that information.

YouTube Dislikes Forrest Knight Python Version 3.0+ Only use if you know what the code actually does. I'm not responsible for your use of this code in

Forrest Knight 155 Dec 19, 2022
Simple VLC-based media player that can play multiple videos at the same time

Screenshots About Simple VLC-based media player that can play multiple videos at the same time. You can play as many videos as you like, the only limi

161 Jan 05, 2023
High-performance cross-platform Video Processing Python framework powerpacked with unique trailblazing features :fire:

Releases | Gears | Documentation | Installation | License VidGear is a High-Performance Video Processing Python Library that provides an easy-to-use,

Abhishek Thakur 2.6k Dec 28, 2022
Source files for the data lake demo video using the AWS TICKIT database

Data Lake Demo Source code for video demonstration detailed in the post, Building a Simple Data Lake on AWS . Build a simple data lake on AWS using a

Gary A. Stafford 97 Dec 23, 2022
Your self hosted Youtube media server

The Tube Archivist Your self hosted Youtube media server Core functionality Subscribe to your favourite Youtube channels Download Videos using yt-dlp

Simon 2.1k Dec 31, 2022
A way to run youtube videos in TTY

TTY youtube client its finally here, the one thing literally NO ONE ASKED FOR!! A way to run youtube videos in TTY Dependencies: (pip) yt-search (syst

1 Nov 28, 2021
Komposition - The video editor built for screencasters

Komposition The video editor built for screencasters Tutorial Video | Introduction | Installation Documentation See the documentation and user guide.

Oskar Wickström 428 Jan 08, 2023
Lightweight, zero-dependency proxy and storage RTSP server

python-rtsp-server Python-rtsp-server is a lightweight, zero-dependency proxy and storage server for several IP-cameras and multiple clients. Features

Vlad 39 Nov 23, 2022
A GUI based datamoshing apllication for everyone! Apply this glitch to your videos and gifs. Supports all video formats!

A GUI based datamoshing apllication for everyone! Apply this glitch to your videos and gifs. Supports all video formats!

Akascape 131 Dec 31, 2022
Streams video from raspberry pi to desktop T1 - Recognizes Faces on client T2

VideoStreamingServer Completed: Streams video from raspberry pi to desktop T1 - Recognizes Faces on client T2 In progress: Change the transmission Pro

1 Dec 06, 2021