How to Convert Video to ASCII with FFmpeg caca
This guide explains how to convert any video file into an ASCII art
video using the powerful FFmpeg multimedia framework and its
caca output device. You will learn how to verify your
FFmpeg installation for compatibility, execute the command to play
videos as ASCII art in your terminal, and export the ASCII stream to a
file.
Step 1: Verify libcaca Support in FFmpeg
Before starting, you must ensure that your FFmpeg installation was
compiled with libcaca support. Run the following command in
your terminal:
ffmpeg -devicesLook for caca in the output list. If it is present, your
FFmpeg version is ready. If it is missing, you will need to install the
libcaca library on your system and install a version of
FFmpeg compiled with the --enable-libcaca flag.
Step 2: Play Video as ASCII Art in the Terminal
To render and play a video as ASCII art directly inside your terminal window, run the following command:
ffmpeg -i input.mp4 -f caca -Replace input.mp4 with the path to your video file. The
-f caca option specifies the caca output
device, and the hyphen - redirects the output to your
active terminal display.
Step 3: Export the ASCII Art Video to a File
The libcaca library allows you to export the rendered
ASCII frames into text-based formats. To save the ASCII video stream
into a text animation file, you can set the CACA_DRIVER
environment variable to ansi and redirect the output to a
file:
CACA_DRIVER=ansi ffmpeg -i input.mp4 -f caca output.ansiYou can play back this .ansi file in your terminal later
using terminal viewing tools or by running
cat output.ansi.
Step 4: Customizing the ASCII Output
You can control the resolution and appearance of the ASCII video by setting environment variables before running the FFmpeg command:
Force a specific resolution: Use
CACA_GEOMETRYto define the width and height in characters.CACA_GEOMETRY=100x40 ffmpeg -i input.mp4 -f caca -Change the rendering algorithm: Use
CACA_DITHERto change how colors are dithered (options includenone,ordered,random, andf Floyd-Steinberg).CACA_DITHER=ordered ffmpeg -i input.mp4 -f caca -