converts images/video to ascii art
make sure you have ffmpeg installed (along with the respective headers)
usually on linux you just install the headers like so:
sudo apt-get install libavutil-dev libavformat-dev libavcodec-dev libswscale-dev
on macos you would do
brew install ffmpeg
on windows:
choco install ffmpeg-full
it is getting too annoying to handle cross plat binary releases using my apple silicon mac. just build from source.
or wait till i release the web app!
zig build -Drelease
the above command builds an executable found at ./zig-out/bin
if you want to just directly run the executable, run:
zig build run -Drelease -- [options]
see below for explanations for available options
run the program with the following options (the default zig install directory is ./zig-out/bin
):
/path/to/asciigen [options]
-
options:
-h, --help
: print the help message and exit-i, --input <file>
: specify the input media file path (local path/URL) (required)-o, --output <file>
: specify the output media file (required)-c, --color
: use color ascii characters (optional)-n, --invert_color
: Inverts the color values (optional)-s, --scale <float>
: set the downscale or upscale factor (optional, default: 1)-e, --detect_edges
: enable edge detection (optional)--sigma1 <float>
: set the sigma1 value for DoG filter (optional, default: 0.3)--sigma2 <float>
: set the sigma2 value for DoG filter (optional, default: 1.0)-b, --brightness_boost <float>
: increase/decrease perceived brightness (optional, default: 1.0) advanced options:--full_characters
: Uses all ascii characters in generated output.--ascii_chars <string>
: Use what characters you want to use in the generated output. (default: " .:-=+*%@#")--disable_sort
: Prevents sorting of the ascii_chars by size.--block_size <u8>
: Set the size of the blocks. (default: 8)--threshold_disabled
: Disables the threshold.--codec <string>
: Set the encoder codec like "libx264" or "hevc_videotoolbox". (default: searches for encoders on your machine)--keep_audio
: Preserves audio from input video.
-
examples:
basic usage:
asciigen -i input.jpg -o output.png
using color:
asciigen -i input.png -o output.png -c
with edge detection, color, and custom downscale:
asciigen -i input.jpeg -o output.png -s 4 -e -c
with brightness boost and url input:
# bonus (this is a sweet wallpaper) asciigen -i "https://w.wallhaven.cc/full/p9/wallhaven-p9gr2p.jpg" -o output.png -e -c-b 1.5
with an input video (no urls allowed):
asciigen -i /path/to/input/video.mp4 -o ascii.mp4 --codec hevc_nvenc --keep_audio
with input video and custom ffmpeg encoder options:
asciigen -i /path/to/input/video.mp4 -o ascii.mp4 -c --codec libx264 --keep_audio-- -preset fast -crf 20
-
the program will generate an ascii art version of your input media and save it as a new media file.
for images: output file needs to be a .png
since i saw some weird issues with jpegs.
the zig version is the only one i'll be working on from here on. the c code was just to get me started until i figured out some issues with the build.zig
- using the long arguments on windows may or may not work. please use the short arguments for now.