Coder Social home page Coder Social logo

joelibaceta / video-to-ascii Goto Github PK

View Code? Open in Web Editor NEW
1.6K 19.0 136.0 148.14 MB

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

License: MIT License

Python 99.60% Dockerfile 0.40%
video terminal opencv python ascii play-videos ansi-colors cli opensource python3

video-to-ascii's Introduction

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

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 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

video-to-ascii's People

Contributors

alexmarginean16 avatar bakkeby avatar cabustillo13 avatar cclauss avatar creativegamer03 avatar desktecc avatar diegodorado avatar douglascdev avatar hsins avatar joelibaceta avatar ksemele avatar monkeywithacupcake avatar mtvare6 avatar roolrz avatar schweinepriester avatar thedude53 avatar themaroonhathacker avatar unjavascripter avatar yigaofan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

video-to-ascii's Issues

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

Describe the bug
Error when trying to play video.
When I run the command, it prints:

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\...\PycharmProjects\badApple\venv\Scripts\video-to-ascii.exe\__main__.py", line 7, in <module>
  File "c:\users\...\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\...\pycharmprojects\badapple\venv\lib\site-packages\video_to_ascii\player.py", line 23, in play
    engine.play(output)
  File "c:\users\...\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\...\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 required modules installed

To Reproduce
Steps to reproduce the behavior:

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

Expected behavior
The video should play.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: N/A
  • Version: 1.2.9

With Audio install failed

Collecting video-to-ascii
  Using cached video_to_ascii-1.2.8.tar.gz (6.0 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-bzdptpyj/video-to-ascii/setup.py'"'"'; __file__='"'"'/tmp/pip-install-bzdptpyj/video-to-ascii/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-nxhmzkc9                
         cwd: /tmp/pip-install-bzdptpyj/video-to-ascii/                                                       
    Complete output (7 lines):                                                                                
    Traceback (most recent call last):                                                                        
      File "<string>", line 1, in <module>                                                                    
      File "/tmp/pip-install-bzdptpyj/video-to-ascii/setup.py", line 17, in <module>                          
        install_package('opencv-python')                                                                      
      File "/tmp/pip-install-bzdptpyj/video-to-ascii/setup.py", line 10, in install_package                   
        main.main(['install', package])                                                                       
    AttributeError: 'function' object has no attribute 'main'                                                 
    ----------------------------------------                                                                  
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.                                                                                                 

I try to install pyaudio after normal installation and use the - a option, but the screen flashes
alsa lib PCM. C: 8424: (SND_ pcm_ recover) underrun occurred

Syntax error

File "bin/video-to-ascii", line 4
d from video_to_ascii import player
^
SyntaxError: invalid syntax

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

ModuleNotFoundError: No module named 'image_processor'

In some installations, the user gets an error message when try to run the command video-to-ascii

Traceback (most recent call last):
  File "/usr/local/bin/video-to-ascii", line 4, in <module>
    import video_to_ascii
  File "/usr/local/lib/python3.7/site-packages/video_to_ascii/__init__.py", line 4, in <module>
    from image_processor import processor
ModuleNotFoundError: No module named 'image_processor'

Translate readme to main spoken languages

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

  • spanish
    or
  • chinese

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

ModuleNotFoundError: No module named 'cv2'

Traceback (most recent call last): File "c:\users\carl-\appdata\local\programs\python\python38-32\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\carl-\appdata\local\programs\python\python38-32\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\carl-\AppData\Local\Programs\Python\Python38-32\Scripts\video-to-ascii.exe\__main__.py", line 4, in <module> File "c:\users\carl-\appdata\local\programs\python\python38-32\lib\site-packages\video_to_ascii\cli.py", line 3, in <module> from . import player File "c:\users\carl-\appdata\local\programs\python\python38-32\lib\site-packages\video_to_ascii\player.py", line 4, in <module> from . import video_engine as ve File "c:\users\carl-\appdata\local\programs\python\python38-32\lib\site-packages\video_to_ascii\video_engine.py", line 3, in <module> import cv2 ModuleNotFoundError: No module named 'cv2'

Windows 10 32bit
Python 3.8

Audio not working

I get the following error:

Traceback (most recent call last):
File "/home/tavi/.local/bin/video-to-ascii", line 33, in
sys.exit(load_entry_point('video-to-ascii==1.3.0', 'console_scripts', 'video-to-ascii')())
File "/home/tavi/.local/lib/python3.10/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/tavi/.local/lib/python3.10/site-packages/video_to_ascii/player.py", line 23, in play
engine.play(output)
File "/home/tavi/.local/lib/python3.10/site-packages/video_to_ascii/video_engine.py", line 36, in play
self.render_strategy.render(self.read_buffer,
File "/home/tavi/.local/lib/python3.10/site-packages/video_to_ascii/render_strategy/ascii_strategy.py", line 126, in render
stream.write(data)
File "/usr/lib/python3.10/site-packages/pyaudio.py", line 585, in write
pa.write_stream(self._stream, frames, num_frames,
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

OS: ArcoLinuxL (Arch Linux)

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;

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 : #80

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

audio not working

The command was supposed to do audio, but fails. but when I do regular mode, it works just fine
here is the error message:
Traceback (most recent call last):
File "/usr/local/bin/video-to-ascii", line 33, in
sys.exit(load_entry_point('video-to-ascii==1.3.0', 'console_scripts', 'video-to-ascii')())
File "/usr/local/lib/python3.10/dist-packages/video_to_ascii-1.3.0-py3.10.egg/video_to_ascii/cli.py", line 21, in main
File "/usr/local/lib/python3.10/dist-packages/video_to_ascii-1.3.0-py3.10.egg/video_to_ascii/player.py", line 19, in play
File "/home/user/.local/lib/python3.10/site-packages/ffmpeg/_run.py", line 313, in run
process = run_async(
File "/home/user/.local/lib/python3.10/site-packages/ffmpeg/_run.py", line 284, in run_async
return subprocess.Popen(
File "/usr/lib/python3.10/subprocess.py", line 971, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1847, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

My OS is Kali Linux.
My Bowser is Firefox.
My python version is 3.10
The python looked like it was trying to open ffmpeg file via subprocess

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

Crash on Python3.8+ due to time.clock() in render_strategy/ascii_strategy.py

Describe the bug
Crash on Python3.8+ due to time.clock() in render_strategy/ascii_strategy.py

on Python3.8+ time.clock() should be replaced bytime.perf_counter() or otherelse
stackoverflow link about that

To Reproduce
Steps to reproduce the behavior:

  1. install python3.9.9
  2. install video-to-ascii
  3. run video-to-ascii
  4. and you will get an error bellow
Traceback (most recent call last):
  File "/Users/xxx/Downloads/AE/./venv/bin/video-to-ascii", line 8, in <module>
    sys.exit(main())
  File "/Users/xxx/Downloads/AE/venv/lib/python3.9/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 "/Users/xxx/Downloads/AE/venv/lib/python3.9/site-packages/video_to_ascii/player.py", line 23, in play
    engine.play(output)
  File "/Users/xxx/Downloads/AE/venv/lib/python3.9/site-packages/video_to_ascii/video_engine.py", line 36, in play
    self.render_strategy.render(self.read_buffer, 
  File "/Users/xxx/Downloads/AE/venv/lib/python3.9/site-packages/video_to_ascii/render_strategy/ascii_strategy.py", line 120, in render
    t0 = time.clock()
AttributeError: module 'time' has no attribute 'clock'

Expected behavior
Hope support python3.9.9

Desktop (please complete the following information):

  • OS: [Macos]
  • Version [12.1]

echo -en ''

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

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.

pip install video-to-ascii not installing

Describe the bug
The pip command throws error and does not install the module
the error is following

Collecting video-to-ascii
  Using cached video_to_ascii-1.3.0.tar.gz (6.9 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  Γ— python setup.py egg_info did not run successfully.
  β”‚ exit code: 1
  ╰─> [15 lines of output]
      Traceback (most recent call last):
        File "C:\Users\ahmed\AppData\Local\Temp\pip-install-9apno99s\video-to-ascii_e8b3c15ce1a440489be86a409ed5aee6\setup.py", line 11, in install_package
          main.main(['install', package])
      AttributeError: 'function' object has no attribute 'main'

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\ahmed\AppData\Local\Temp\pip-install-9apno99s\video-to-ascii_e8b3c15ce1a440489be86a409ed5aee6\setup.py", line 21, in <module>
          install_package('opencv-python')
        File "C:\Users\ahmed\AppData\Local\Temp\pip-install-9apno99s\video-to-ascii_e8b3c15ce1a440489be86a409ed5aee6\setup.py", line 14, in install_package
          __main__._main(['install', package])
      AttributeError: module 'pip.__main__' has no attribute '_main'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Γ— Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Desktop (Windows)

  • OS: Windows 10
  • Currently running on Windows-10-10.0.19044-SP0

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.

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.

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.

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

I'm trying to run video-to-ascii on Python 3.8 and encounter the following error:

Traceback (most recent call last):
  File "/home/biazzotto/python/video-to-ascii/.venv/bin/video-to-ascii", line 8, in <module>
    sys.exit(main())
  File "/home/biazzotto/python/video-to-ascii/.venv/lib/python3.8/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/biazzotto/python/video-to-ascii/.venv/lib/python3.8/site-packages/video_to_ascii/player.py", line 23, in play
    engine.play(output)
  File "/home/biazzotto/python/video-to-ascii/.venv/lib/python3.8/site-packages/video_to_ascii/video_engine.py", line 36, in play
    self.render_strategy.render(self.read_buffer, 
  File "/home/biazzotto/python/video-to-ascii/.venv/lib/python3.8/site-packages/video_to_ascii/render_strategy/ascii_strategy.py", line 120, in render
    t0 = time.clock()
AttributeError: module 'time' has no attribute 'clock'

Python version: 3.8.2 (from Ubuntu 20.04 LTS)
video-to-ascii version: 1.2.8

This is caused by removing time.clock() function in Python 3.8, as warned here: Deprecated since version 3.3, will be removed in version 3.8: The behaviour of this function depends on the platform: use perf_counter() or process_time() instead, depending on your requirements, to have a well defined behaviour..

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

Error when trying to install on pip

Im getting this error after trying to install it on kali linux wsl2 or windows normally.


Defaulting to user installation because normal site-packages is not writeable
Collecting video-to-ascii
  Downloading video_to_ascii-1.3.0.tar.gz (6.9 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  Γ— python setup.py egg_info did not run successfully.
  β”‚ exit code: 1
  ╰─> [15 lines of output]
      Traceback (most recent call last):
        File "/tmp/pip-install-k19bynbv/video-to-ascii_168962df3c8d49358f05e874508b0ea7/setup.py", line 11, in install_package
          main.main(['install', package])
      AttributeError: 'function' object has no attribute 'main'

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-k19bynbv/video-to-ascii_168962df3c8d49358f05e874508b0ea7/setup.py", line 21, in <module>
          install_package('opencv-python')
        File "/tmp/pip-install-k19bynbv/video-to-ascii_168962df3c8d49358f05e874508b0ea7/setup.py", line 14, in install_package
          __main__._main(['install', package])
      AttributeError: module 'pip.__main__' has no attribute '_main'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Γ— Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

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.

not working on windows python 3.7

i have an error when i download the module and i open cmd i put video-to-ascii -f video.mp4 but is not working

this is the error:

ascii_strategy.py", line 121, in render
rows, cols = os.popen('stty size', 'r').read().split()
ValueError: not enough values to unpack (expected 2, got 0)

Playing Speed Option

Hi, it works much well (without audio).

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

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

Fix windows compatibility

Some incompatibilities do not allow this tool to run correctly on windows. I will list some of them:

  • The stty size command is used to obtain the terminal's size, which generates the unknown command error in windows.

ZeroDivisionError: float division by zero

root@mail:/disk1# video-to-ascii -f wild.mp4
Traceback (most recent call last):
File "/usr/local/bin/video-to-ascii", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/video_to_ascii/player.py", line 23, in play
engine.play(output)
File "/usr/local/lib/python3.6/dist-packages/video_to_ascii/video_engine.py", line 38, in play
with_audio=self.with_audio)
File "/usr/local/lib/python3.6/dist-packages/video_to_ascii/render_strategy/ascii_strategy.py", line 113, in render
time_delta = 1./fps
ZeroDivisionError: float division by zero

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/

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

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

How to run this with python?

Hi, I saw the video on Linkedin I think is really cool! Thanks!
I was trying to running this with Phyton like:

python -m video_to_ascii.cli

And the following error is printed:

File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/Users/benjaminaguilar/Documents/work/videoToAscii/video_to_ascii/cli.py", line 3, in <module> from . import player File "video_to_ascii/player.py", line 4, in <module> from . import video_engine as ve File "video_to_ascii/video_engine.py", line 4, in <module> from . import render_strategy as re File "video_to_ascii/render_strategy/__init__.py", line 1, in <module> from . import ascii_bw_strategy as bw File "video_to_ascii/render_strategy/ascii_bw_strategy.py", line 5, in <module> from . import ascii_strategy as strategy File "video_to_ascii/render_strategy/ascii_strategy.py", line 158 SyntaxError: Non-ASCII character '\xe2' in file video_to_ascii/render_strategy/ascii_strategy.py on line 158, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

I am in OSX, and I have installed opencv and xtercolor

pip install opencv-contrib-python
pip install xtermcolor

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.