CLI and utilities for converting media files (images/videos) to ascii outputs (output media file or print to console)

Overview

Media-To-Ascii

CLI and utilities for converting media files (images/videos) to ascii outputs (output media file or print to console).
Supports most standard image formats, and some video formats.

Only output format for videos is .mp4 at the moment

Examples

mediatoascii is capable of extremely high quality ascii images/videos (click on the images below to see the full resolution), or the usual fun scaled-down ones!

Videos

(From https://www.tiktok.com/@swishanime_/video/7143035431066602794)

Or for a more high quality version: https://i.imgur.com/vRJMpA1.mp4

Images

happy_image

discprof

&&&#&&&&GP&&&&&&G&G#&G5J#J#PPP#&JGG7#GPYGGPP5GGPPJGGGP55G5#JGPPP7JJ557JP5JY55JYJPPPY75PJ5PPPPPPP555JJ55JJJJ
&#&&&&&&P5GG&&&&P&#G&&Y5J5JY55YGGJ55#BBBPPG555PPJJJPGG557G5GPP55555YJJYPP5JJ5Y55PYPPPPPPPPPPP555555JJP5JJJ5
P&&#&&&&5JGY#GG&&&&?JJ5?YGG?J5G?BBBBBBBBJ#G5JJJJ5JJY5555JJ55P5J75P?Y?JP75555PP5Y?PPPPPYYJJJ5PY#JJJ55P575
5P#P#&YG7#57&&&&YJPGPPGPPGG5&BBBBBBBBBGGGGJGG5555PP5J555JPJ7GBBBBBBPPY55PYPPPPP?JG@@@@@@@YY5555555557
5J#5P###5Y5JP5P#55GYPPPPPPPPPYJJYGBBBBBBBBBBBBBBBBB&#PJYJGYJJYBBBBBBBBBBBB7PPPYP5PPPJB@@@@@@@B7P5PPP555555P
5YP55GP#PJY5~55GPPPPPPPPPPPPPPPPYBBBBBBBBBBBB7JGBGJYBBBBBBBBBBBBBBBBBBBBBB7JJJ55JYJ?P&@@@@GG?55J777777J5PPP
YJ5JJ5YJG&&&&&J?GJ&#Y5PPPPPPPPPYBBBBBBBBBBBBBBB5YYY7BBG7BBBBBBBBBBBBBBBBBB7JJJPPJ5YP55PPG#~?7YYJJJJJ5PP5557
#&&#######&#######&##7JJ7YJJJ5Y&BBBBBBBBBBBBBB7YYYYYY&BBBBBBBBBBBBBBBBBBBB7PPPPPPGJ5555Y?555555555J###GGGP5
##&&#&&&&&&&GGJJ#GP5PPPPPPPPPP5BBBBBBBBBBBBBBBYYYYYY7BBBBBBBBBBBBBBBBBBBB#??7?JPP75555Y~PPP5JY555575###PJYG
&&&GYPPPPPPPPPPPJYYY77?JPJPPPY&BBBB&&&&&&&&&&&B&&&&&&BBBBBBBBBBBBBBBBBBB&?GPPPPPG~55557PJJPJ5J57#G7PPPPP5#7
&#JPGYJJ575PYPPP5PP5PPPPPPPP7YJ55555555555575555555555YY#&&BB&&&&&&B&&&#PYGGGGGGGY555Y?PPPPPPJYPPP5J5?7P~YY
&&&&&&&&&&&P5#PPJJYYYPPP7?7B?555555JJ55YJ555J5555555J7555555Y7P&&&&&&&G555GGGGGG55555Y?GPPPPPPPPJ5JYP???YYY
BBBBBBBBB&&&&&&&&&&&&&&&&&&P55557@@@@@@@@&J555555555555JYY77555557J##555YJPGGGGGY55557PGGGPPPPPPPPJJPPPPJ5P
BBBBB&BBBBBBBBBBBBBBBBB&&&&75555@@@Y~~~7@@Y5555555555Y@@@@@@@BY5555J7J55?#######?55557#GGGGGGJJPPP55P?P555Y
Y5B&PJ@@BBBBBBBBBBBBBBBBBBBY55Y@@@&~~~~~@@P555555557@@@&~~~?B@@Y5555J7?7&&&&&&#G~555J~GY777Y5J??P7?5PPGGPGY
7JY?7JYGBJ@@@@B@BBBBBBBBBBB5557@@@@@GP#@@@J5555555JB@@B~~~~~5@@@Y555Y7?B&&G5&&PJY55577PPPP5J55PPPPPPP55PPPP
PP?57Y77JJBB@GPJ77JGBB@BBBBJ555P@@@@@@@@@#555555557@@@@&~~~G@@@@Y55577?BBB&&&&&5555575P&P###GPPP77YJ555JP55
YY5&@&?JY&BBB@@@@@@@@@@@@#555P555JJ5P5YY555JJ555555J@@@@@@@@@@@7555J77#BBBBBB&B?555Y?&&&#########5GPG7J7JYY
@GP5@BBBBBBBB@@@@BB@@BB@@Y55G&�J~:Y55555557#@@@@@@B?5555777BBBBBBBBG55557&&&###############G###G
BBBBBBBBBBB@@@@@@@@@@@@@@?555555555555555JJ7J55555555555555PP55555J7?BBBBBBBBB7555Y7&&#####################
@@@@@@@@@@@@@@@@@@@@@@@@G5Y?J5J55JJ555JJJ5JJJ77YYJ555555555PGG55JJY?YY5BBBBBB755JJ?&&&&&&&&&&&#############
@@@@@@@@@@@@@@@@@@@@@@@@@@@B?7JJJJJJJJJJJJJJJJJJJJJ55JJ555555JJJJY7:YYYY5BBB55J5Y7#B&&&&&&&&&&&&###########
@@@@@@@@@@@@@@@@@@@@@@@@@JYYYYY7~7JJJJJJJJJJJJJJJJJJJJJJJJJJJJ?Y~:7YYYYYY7&G77Y77#BBBBBBBBB&&&&&&&&&&&&&&&&
@@@@@@@@@@@@@@@@@@@@@@@PYYYYYYYY??JY~?77JJJJJJJJJJJJJJJJJY77??:???YYYYYYYYY~7777GBBBBBBBBBBBBBBBBBB&&&&&&&&
@@@@B@@@@@@@@@@@@@@@@B7YY???755JJJJJJ~?P^::?~~:~::::~~??:Y~~????7YYYYYYYYYYY:7?BB@@@@@@@@@@@BBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBB?Y~J5JJJJJJJJJYJPPPY~:Y^7777?YG77JJJJJJJJY^?YYYYYYYYYYY7GB@B@@@@@@@@@@BBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBJYYY7Y7?~~::::GPPPPP?5&BYG?PPPP57JJJJJJJJJJJJJ77YYYYYYYY7?BBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBB&~YYY77777Y7????:Y#&BBBBBB&?JPPPPP?JJY~YJJJJJJJJJJJ?7Y77Y?~BBBBBBBBBBBBBBBBBBBBBBBBBBBBB
&&&&&&B&&&&&&&&&&&&G~7777777777?~7GJPBBBBBBBBBBB5PPPP7JY77B&??~^YJJJJJJ7?777?:B&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&P:?7777777777~G7J#&&&&BB&&&&&&&&&BY???:&&~~77777~JJ~:777?~7&&&&&&&&&&&&&&&&&##&#########
&&&&&&&&&&&&&&&&&&&&Y:77777777777?5#G7G&&&&&&&&&&&&P5??~7J~~77777777777777?~7&####################GGGGGGGGG
&&&&&&&&&&&&&&&&&&&&PP^?777777777777??5GGG5Y7????~~?YYY~?777777777777777??:YP#############GGGGGGGGGGGGGGGGG
&&&&&#########&&&&#&##J7~?77777777777777777777777777777777777777777777?~~~?#########GGGGGGGGGGGPPPPPPPPPPPP
#######################YP~:?777777777777777777777777777777777777777?~~::5P#########GGGGGGGGGGGGGPPPPPPPPPPP
#########################Y55^~~?7??77777777??7777??????7777777??~~~::P?G#GGGGGGGGGGGGGGGGGGGGGGGGPPPPPPPPPP
#########################G##7YP~::~~~~????????????????????~~~~~::JP?JJJJJGGGGGGGGGGGGGGGGGGGGGGGGGGPPPPPPPP
GGGGGGGGGGGGGGGGGGGGGGGGGJJJJJY7~YPY:::::~~~~~~~~~~~~~~:::::YPY~7:JYYYYYYYPGGGGGGGGGGGGGGGGGPPPPPPPPPPPPPPP
GGGGGGGGGGGGGGGGGGGGGGGGJJJJYYYYJJ?:77?~~7J555JJJJJY7?::::::YYY?YYYYYYYYYYYPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
GGGGGGGGGGGGGGGGGGGGGGGGYJJYYYYYJ:~~~~~~~7JJYYYYYY7:~77777?~^^YYYYYYYYYYYYYPPPPPPPPPPPPPPPPPPPPPPPP55555555
GGGGGGGGGGGGGGGGGGGGGGGPPPYYYYYY^~~~~~~~~YYYYYYYYYYYYYYY~~~~~:YYYYYYYYYYYY5PPPP5555555555555555555555555555
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPYYYYY::~YYYYYYYYYYYYYYYYYY:~~~~~~:YYYYYYYY555555555555555555555555555555555555
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPJYYYYYYYYYYYYYYYYYYYYYY^~:~:~:777Y5555555555555555555555555555555555JJJJJJJ
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP55JY777777777777777777YJ55555555555555555555J5JJJJJJJJJJJJJJJJJJJJJJJJJJ

How To Use

Basic Usage

Videos

# Playing videos as ascii art in the console (warning, for large videos, this may cause flickering on certain terminals)
mediatoascii --video-path 

# Saving ascii art as a video file (only .mp4 is supported as the output format)
mediatoascii --video-path  -o ascii.mp4

# Scale down the video by 2x so file size is smaller in storage and resolution
mediatoascii --video-path  -o ascii.mp4 --scale-down 2.0

Images

# Converting images to ascii in the console
mediatoascii --image-path 

# Outputting ascii images in an image file
mediatoascii --image-path  -o ascii.png

# Outputting ascii images as ascii text in a file
mediatoascii --image-path  -o ascii.txt --as-text

For the full set of features, see the --help menu:

$ mediatoascii --help
mediatoascii 0.1.0
spoorn
CLI and utilities for converting media files (images/videos) to ascii outputs (output media file or
print to console).
Supports most standard image formats, and video formats.

USAGE:
    mediatoascii [OPTIONS] <--image-path |--video-path >

OPTIONS:
        --image-path 
            Input Image file.  One of image_path, or video_path must be populated

        --video-path 
            Input Video file.  One of image_path, or video_path must be populated

        --scale-down 
            Multiplier to scale down input dimensions by when converting to ASCII.  For large
            frames, recommended to scale down more so output file size is more reasonable [default:
            1]

        --height-sample-scale 
            Rate at which we sample from the pixel rows of the frames.  This affects how stretched
            the output ascii is in the vertical or y-axis [default: 2.4]

    -i, --invert
            Invert ascii greyscale ramp (For light backgrounds.  Default OFF is for dark
            backgrounds.)

        --overwrite
            Overwrite any output file if it already exists

        --max-fps 
            Max FPS for video outputs.  If outputting to video file, `use_max_fps_for_output_video`
            must be set to `true` to honor this setting.  Ascii videos in the terminal default to
            max_fps=10 for smoother visuals

        --as-text
            For images, if output_file_path is specified, will save the ascii text as-is to the
            output rather than an image file

    -o, --output-file-path 
            Output file path.  If omitted, output will be written to console. Supports most image
            formats, and .mp4 video outputs

        --use-max-fps-for-output-video
            Use the max_fps setting for video file outputs

    -r, --rotate 
            Rotate the input (0 = 90 CLOCKWISE, 1 = 180, 2 = 90 COUNTER-CLOCKWISE)

    -h, --help
            Print help information

    -V, --version
            Print version information

Installation

Prerequisite: OpenCV

OpenCV 4.x is required on the system.

mediatoascii depends on OpenCV Rust Bindings which require the OpenCV C++ libraries to be installed. See below for instructions on different systems. This should be a one-time setup.

Ubuntu/Linux/WSL2

You'll need to be on Ubuntu 20.04+ for OpenCV 4.x.

To check Ubuntu version:

lsb_release -a

If you are on an older version of Ubuntu, see various tutorials for updating your system.

Install OpenCV and related libs:

sudo apt install libopencv-dev clang libclang-dev

Check OpenCV version:

dpkg -l | grep libopencv

MacOS

Install OpenCV:

brew install opencv

Check OpenCV version:

brew info opencv

Windows

Currently only supported through WSL2 - allowing a Linux subsystem with a terminal to run on Windows: https://learn.microsoft.com/en-us/windows/wsl/install.

Then you can follow the Ubuntu setup above.

Note: on WSL2, drives in paths are prefixed with /mnt/c/ rather than C:/

Arch Linux

Install OpenCV:

pacman -S clang qt5-base opencv

Installing mediatoascii

Below are different ways you can install mediatoascii

[Optional] Cargo

If you choose an installation method below that involves the cargo command, you'll want to install the rust toolchain which includes cargo if you don't already have it: https://doc.rust-lang.org/cargo/getting-started/installation.html

[Recommended] Cargo binstall Binaries

# Install cargo-binstall
cargo install cargo-binstall

# Install mediatoascii
cargo binstall mediatoascii

Portable Binaries

Pre-compiled binaries are available to download and use immediately under Releases. These don't require compiling/building dependencies so installation is much faster. Select the one for your system

  • mediatoascii-x86_64-unknown-linux-gnu for Linux-based systems (Ubuntu/WSL2/etc.)
  • mediatoascii-x86_64-apple-darwin for macOS

Extract the artifacts, then you can then run the binary like any shell/script file in a terminal e.g. ./path/to/mediatoascii |`cd path/to/mediatoascii && mediatoascii , or you can add it to your system PATH so it can be run from any directory. You can easily find tutorials on the internet for "add a binary file to system PATH" for your OS system.

Crates.io

cargo install mediatoascii

Git

# Clone repository and cd into it
git clone ...
cd mediatoascii/

# Install the package into cargo
cargo install --path .

# OR run the pre-packaged binary in bin/
./bin/mediatoascii ...

# OR via `cargo run`
cargo run --release

Troubleshooting

  1. If you're trying to update Ubuntu on WSL2, you may run into silent failures during the upgrade
  2. error while loading shared libraries: libopencv_videoio.so.4.2: cannot open shared object file: No such file or directory
    • Make sure you have OpenCV 4.x installed
You might also like...
Encoding and decoding images in Rust
Encoding and decoding images in Rust

Image Maintainers: @HeroicKatora, @fintelia How to contribute An Image Processing Library This crate provides basic image processing functions and met

Image processing proxy and API, created to allow faster media delivery for the Holaplex storefront.

Description imgopt is an image processing proxy with a very simple API, created to download and dynamically scaledown, convert, and cache different me

A Rust library for calculating perceptual hash values of images

img_hash Now builds on stable Rust! (But needs nightly to bench.) A library for getting perceptual hash values of images. Thanks to Dr. Neal Krawetz f

Zero dependency images (of chaos) in Rust
Zero dependency images (of chaos) in Rust

bifurcate-rs Zero dependency images (of chaos) in Rust To run: time cargo run --release img.pgm To convert from PGM to PNG using Image Magick: conve

Converts images into textual line art.
Converts images into textual line art.

img2utf Transform images to textual line art! Images require pre-processing to come out nice. It's expected that users will do the following: Apply ga

Automated image compression for efficiently distributing images on the web.

Imager Apparently this project made it into the GitHub Archive Program. About Imager is a tool for automated image compression, and can competitively

Fetch original quality URLs for images posted to a Twitter account

twitter-images Fetches the last tweets of a given account, then prints original quality URLs for all image tweets. Useful for archiving image content

Pretty social media preview thumbnails on the edge
Pretty social media preview thumbnails on the edge

pretty-grauniad-thumbnails Created for the Guardian Fastly Hack day. I aimed to improve the rendering of our social media post sharing thumbnail image

mico (minimalistic config file format) encoder and decoder

mico This library implements a parser and emitter for mico (minimalistic config file format). Format example: Name: mico Description: minimalistic con

Releases(0.3.0)
A simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art version constructed with emoji

EmojiPix This is a simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art vers

Michael Milton 22 Dec 6, 2022
Slideo: This tool uses OpenCV to automatically synchronize slides with videos that show these slides.

This tool matches video frames against PDF pages by using computer vision. It also ships a web app in which you can click on a PDF page to play the video from the first frame showing the page. Its primary use-case is to quickly play a recorded lecture from a given slide.

Henning Dieterichs 78 Oct 7, 2022
Convert Sketchbook Tiff Files to Open Raster Images

SketchbookTiffConverter Convert Sketchbook Tiff Files to Open Raster Images and retain layer information. This is a command line program that will con

Phil Spindler 3 Nov 2, 2021
Simple CLI program to generate zoomable tiled images

zoomtiler Simple CLI program to generate deepzoom zoomable tiled images. The input can either be a single image or multiple images of the same height,

Matthieu Pizenberg 3 Mar 14, 2022
A programming language where comments are the first-class citizen and ASCII art flowcharts are the controls!

regretti ?? A programming language where comments are the first-class citizen and ASCII art flowcharts are the controls! Made for Lang Jam (jam0001) t

Mufeed VH 15 Dec 27, 2022
Convert your ascii diagram scribbles into happy little SVG

Svgbob Svgbob can create a nice graphical representation of your text diagrams. Svgbob provides a cli which takes text as an input and creates an svg

Jovansonlee Cesar 3.4k Dec 25, 2022
A Simple Image to Ascii converter in Rust

Image to Ascii A Simple Image to Ascii converter in Rust Brief ?? In my way to learn Rust i decided to make this converter. Challenges ?? new to Rust

WasixXD 7 Sep 16, 2022
Takes a folder of images (as a palette), and an image, and figures out how to tile the palette to resemble the image!

Takes a folder of images (as a palette), and an image, and figures out how to tile the palette to resemble the image!

Jacob 258 Dec 30, 2022
🖼️Combines a Javascript and WASM file into a single executable polygot PNG+HTML file.

WASIMAGE Combines a Javascript and WASM file into a single executable polygot PNG+HTML file. Usage: cargo install wasimage wasimage --wasm-file my.was

Nervive 2 Mar 30, 2022
Encoding and decoding images in Rust

Image Maintainers: @HeroicKatora, @fintelia How to contribute An Image Processing Library This crate provides basic image processing functions and met

image-rs 3.5k Jan 9, 2023