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]

Issues
  • 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
  • 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
  • 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
  • added windows support

    added windows support

    tested on window 10

    opened by Nex4rius 4
  • 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
  • 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
  • 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
  • replace time.clock() with time.process_time()

    replace time.clock() with time.process_time()

    Because clock api is removed on Python3.8.

    opened by YigaoFan 2
  • Audio is out of sync with the video

    Audio is out of sync with the video

    running this through linux terminal and the video portion is working great, however audio is choppy, will cut out for a microsecond pretty frequently and drifts out of sync pretty heavily the longer the video is.

    the bottom of the linux terminal also complains about under runnage through lib pcm?

    • OS: Linux Mint
    opened by BenjaminEide 0
  • Installation Error with Audio

    Installation Error with Audio

    I was using Macbookpro.

    In the terminal, I typied pip3 install video-to-ascii --install-option="--with-audio". It poped up ERROR: command errored our with exit status 1. Here is the screenshot image

    opened by EhanDuan 0
  • Playing Speed Option

    Playing Speed Option

    Hi, it works much well (without audio).

    Just wonder if there is the option to adjust the playing speed?

    idea 
    opened by EhanDuan 0
  • Unresolved file reference in README

    Unresolved file reference in README

    The README.md file references CONTRIBUTING.md but this file doesn't exist. Is it supposed to, or should the reference be removed?

    opened by douglascdev 0
  • Typos discovered by codespell

    Typos discovered by codespell

    This is a Good First Issue to fix the following typos

    ./video_to_ascii/cli.py:8: usefull ==> useful
    ./video_to_ascii/render_strategy/ascii_strategy.py:72: correcly ==> correctly
    ./video_to_ascii/render_strategy/ascii_strategy.py:72: builded ==> built
    ./video_to_ascii/render_strategy/image_processor.py:1: usefull ==> useful
    ./video_to_ascii/render_strategy/image_processor.py:14: apropiate ==> appropriate
    ./video_to_ascii/render_strategy/image_processor.py:23: apropiate ==> appropriate
    ./video_to_ascii/render_strategy/image_processor.py:57: brighness ==> brightness
    ./bin/video-to-ascii:6: usefull ==> useful
    
    good first issue 
    opened by cclauss 0
  • Installation failed on Ubuntu 18.04.5

    Installation failed on Ubuntu 18.04.5

    Hi ! In love of your work I would like to use it ! I tried to install it but fail with this error that I don't get : Is there something I could do to fix it ? Does this come of my computer or is it a well known bug ? If I can help I'll be happpy !

    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
      Using cached https://files.pythonhosted.org/packages/42/36/b3ba2181793646f6c32234527ab51e74905a10139273a1056cf717367504/video_to_ascii-1.3.0.tar.gz
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-build-fp1jbfaw/video-to-ascii/setup.py", line 21, in <module>
            install_package('opencv-python')
          File "/tmp/pip-build-fp1jbfaw/video-to-ascii/setup.py", line 10, in install_package
            from pip._internal import main
        ModuleNotFoundError: No module named 'pip._internal
        
        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-fp1jbfaw/video-to-ascii
    
    bug 
    opened by vincentkollebolle 3
  • A feature to export every ASCII frame to a text file

    A feature to export every ASCII frame to a text file

    Is your feature request related to a problem? Please describe. To me, this utility is amazing, and very easy to use. I also want to use it for other projects, and I think if there is an option for exporting frames, it will be easier to use the ASCII outputs in different projects.

    Describe the solution you'd like Maybe some parameter like --export or -e which takes a folder and exports colorless ASCII output by creating text files for each frame.

    For example, if --export testfolder/testsubfolder passed, the program can create testfolder/testsubfolder/0.txt for frame 1 and write the first frame's ASCII output. Then it creates testfolder/testsubfolder/1.txt for frame 2 and so on.

    Describe alternatives you've considered Maybe editing bash output to create something like this.

    idea 
    opened by devygz 1
  • AttributeError: module 'time' has no attribute 'clock'

    AttributeError: module 'time' has no attribute 'clock'

    Describe the bug Error when trying to run video

    To Reproduce Steps to reproduce the behavior:

    1. Go to terminal
    2. type video-to-ascii -f myvideo.mp4
    3. See error

    Expected behavior When i run command in terminal it displays:

    Traceback (most recent call last):
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "C:\Users\CripoGames\PycharmProjects\badApple\venv\Scripts\video-to-ascii.exe\__main__.py", line 7, in <module>
      File "c:\users\cripogames\pycharmprojects\badapple\venv\lib\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 "c:\users\cripogames\pycharmprojects\badapple\venv\lib\site-packages\video_to_ascii\player.py", line 23, in play
        engine.play(output)
      File "c:\users\cripogames\pycharmprojects\badapple\venv\lib\site-packages\video_to_ascii\video_engine.py", line 36, in play
        self.render_strategy.render(self.read_buffer,
      File "c:\users\cripogames\pycharmprojects\badapple\venv\lib\site-packages\video_to_ascii\render_strategy\ascii_strategy.py", line 120, in render
        t0 = time.clock()
    AttributeError: module 'time' has no attribute 'clock'
    

    I have all needed modules installed

    Screenshots Screenshot

    Desktop (please complete the following information):

    • OS: Windows 10
    • Browser Uhhh i'm running this on PyCharm not browser
    • Version 1.2.9
    bug 
    opened by Wolfyxon 5
  • Add option to loop/repeat video?

    Add option to loop/repeat video?

    Is your feature request related to a problem? Please describe. No problem per se, just a feature request or rather a suggestion.

    Describe the solution you'd like I want the generated ASCII video/animation to play repeatedly, in my case indefinitely i.e. looping until I press e.g. ctrl + c.

    Describe alternatives you've considered I've helped myself with

    while true; do video-to-ascii -f myVid.mp4; done
    

    but there's a flash of black between loops.

    Additional context Not sure when the ASCII is generated, but if its not on the fly for each frame, there would be potential here to cache it.

    Feel free to close if you dont think this feature would be useful or the like.

    idea 
    opened by Schweinepriester 1
  • echo -en ''

    echo -en ''

    When I try to run the command (video-to-ascii -f video.mp4) it just responds with echo -en '' echo -en '' It doesn't play the video and just says that.

    opened by pog222 4
Releases(1.2.9)
Owner
Joel Ibaceta
Software Engineer, Fintech Expert, Technical Advisor, Digital Nomad, Open Source Contributor, Investor
Joel Ibaceta
Program to play videos with props in Apex Legends

R5Fresh A video player for the Apex Legends mod R5Reloaded

null 5 Nov 28, 2021
Convert lecture videos to slides in one line. Takes an input of a directory containing your lecture videos and outputs a directory containing .PDF files containing the slides of each lecture.

Convert lecture videos to slides in one line. Takes an input of a directory containing your lecture videos and outputs a directory containing .PDF files containing the slides of each lecture.

Sidharth Anand 12 Nov 25, 2021
A simple Telegram bot to extract hard-coded subtitle from videos using FFmpeg & Tesseract.

Video Subtitle Extractor Bot A simple Telegram bot to extract hard-coded subtitle from videos using FFmpeg & Tesseract. Note that the accuracy of reco

null 10 Nov 23, 2021
TkVideoplayer - This is a simple library to play video files in tkinter.

TkVideoplayer - This is a simple library to play video files in tkinter.

Art/Paul 3 Oct 20, 2021
This plugin generates json files used by deovr allowing you to play 2d and 3d video's using the player

deovr-plugin This plugin generates json files used by deovr allowing you to play 2d and 3d video's using the player. Deovr looks for an index file /de

null 1 Nov 29, 2021
Play Video & Music on Telegram Group Video Chat

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

Jonathan 2 Nov 28, 2021
Python Script for Streaming YouTube Videos in VLC Media Player.

Short Description Use this Simple Script to stream YouTube Video to VLC

Sijey 6 May 27, 2021
A python generator that converts youtube videos to ascii art in your console.

Video To ASCII A python generator that converts youtube videos to ascii art in your console. This has not been tested for windows! Example Normal mode

Julian Jones 15 Nov 12, 2021
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

Adnan Ahmad 49 Nov 22, 2021
pygamevideo module helps developer to embed videos into their Pygame display

pygamevideo module helps developer to embed videos into their Pygame display. Audio playback doesn't use pygame.mixer.

Kadir Aksoy 7 Oct 10, 2021
Playing videos through S3 buckets (Wasabi, AWS, etc.) through client-side VideoJS player

Playing videos through S3 buckets (Wasabi, AWS, etc.) through client-side VideoJS player without incurring ingress/egree traffic on EC2 Instance.

Syed Umar Arfeen 5 Jun 19, 2021
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.

null 26 Sep 4, 2021
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 92 Nov 25, 2021
Text2Video's purpose is to help people create videos quickly and easily by simply typing out the video’s script and a description of images to include in the video.

Text2Video Text2Video's purpose is to help people create videos quickly and easily by simply typing out the video’s script and a description of images

Josh Chen 9 Nov 18, 2021
Script simples para baixar vídeos/áudios/playlist do YouTube

?? VilelaTube ▶️ Script simples para baixar vídeos/áudios/playlist do YouTube Requisitos • Como usar • Melhorias futuras ⚠️ Atenção! ⚠️ Lembre-se de a

João Victor Vilela dos Santos 2 Nov 3, 2021
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 1 Nov 17, 2021
DICexport is a GUI (PyQt5) to export digital image correlation videos

DIC Video Exporter DICexport is a GUI (PyQt5) to export digital image correlation videos. It offers the flexibility to choose a selected range of a vi

Chaoyi Zhu 1 Nov 9, 2021
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 74 Nov 25, 2021
A telegram bot for compressing/encoding videos in h264 format.

Video-Encoder-Bot a telegram bot for compressing/encoding videos in h264 format. Configuration Add values in environment variables or add them in conf

Weeb >.< 3 Nov 22, 2021