ascii_videos

A project that converts video to ascii characters and print them in the terminal.

Environment

Before start, make sure you have ffmpeg installed.

$ ffmpeg
ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
...

If not, this is a sample installation on Ubuntu:

$ sudo apt install ffmpeg

Or compile by source code:

$ wget http://www.ffmpeg.org/releases/ffmpeg-5.1.tar.gz
$ tar -zxvf ffmpeg-5.1.tar.gz
$ cd ffmpeg-3.1
$ ./configure --prefix=/usr/local/ffmpeg
$ make
$ make install

Example

Load a image from remote or local path, convert rgb to gray matrix, and calculate ascii characters to instead.

// load image
img, err := LoadImage("https://i0.hdslb.com/bfs/new_dyn/cd115a1ab8a69f121ac1ab740f45b12a173469252.png")

// image to ascii
bytes := image2Ascii(img)

// clear
cmd := exec.Command("clear")
cmd.Stdout = os.Stdout
cmd.Run()

// print
fmt.Println(string(bytes))

Result

img

image-20220815211000843

img

image-20220815210749832

GitHub

View Github