understandable linux tips, tricks and tutorials

Playing a movie using ascii art is probably the ulimate in anti-eyecandy, but it’s a cool trick for impressing your friends, or if you’re stuck in a tty, can’t start X, and just have to watch the latest episode of Lost. Mplayer has the ability to display movies in ascii art in both black and white and in colour. We’ll deal with each in turn.

black and white

To play a movie in ascii art, you’ll need mplayer and a library called aalib. Mplayer (along with xine) is one of the more popular video player/engines for linux, and therefore should be available in the repository for your distribution. aalib is also commonly included in distribution repositories. If not you’ll have to compile it from source. To play a movie in ascii art, all you’ll need to do is run the following command in a terminal:

mplayer -vo aa movie.avi

This will give you something like this (which just happens to be the opening "don’t try this at home" scene from Mythbusters):

You can also play with things a bit as well. These are some of the controls available:

  • Important suboptions:
    • extended: use use all 256 characters
    • eight: use eight bit ascii
    • driver: set recommended aalib driver (X11,curses,linux)
    • help: to see all options provided by aalib
  • AA-MPlayer Keys
    • 1 : contrast -
    • 2 : contrast +
    • 3 : brightness -
    • 4 : brightness +
    • 5 : fast rendering
    • 6 : dithering
    • 7 : invert image
    • a : toggles between aa and mplayer control

The first four suboptions can be added to the command line following the "-vo aa" argument, separated by a ":". For example:

mplayer -vo aa:extended:driver=curses:contrast=50 movie.avi

The "AA-MPlayer Keys" are used while the video is running to adjust various display and performance aspects of playback. You can also pass a height and width parameter to change the resolution of the video. An important viewing tip is that squinting often helps.

full technicolour

If you prefer your movies in colour, there’s another ascii lib that mplayer uses called libcaca. libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals. It is a lot like aalib, but includes unicode support, 2048 colours, dithering of colour images and advanced text canvas operations. libcaca works in a text terminal (and should work on all Unix systems including Mac OS X) using the S-Lang or ncurses libraries. It also works natively on DOS and Windows. libcaca came installed on ubuntu (either as an mplayer dependency, or installed by default – I don’t remember installing it separately), and may be available in your distribution’s repository. Otherwise you’ll have to compile it. Again to play a video using libcaca, enter the following command in a terminal:

mplayer -vo caca movie.avi

and you’ll get something like this (which just happens to be the opening "don’t try this at home" scene from Mythbusters, so you can compare with the aalib version above):

You can manipulate the playback using environment variables:

  • CACA_DRIVER: set the backend video driver. In order of preference:
    • conio uses the DOS conio.h interface.
    • ncurses uses the ncurses library.
    • slang uses the S-Lang library.
    • x11 uses the native X11 driver.
    • gl uses freeglut and opengl libraries.
    • raw outputs to the standard output instead of rendering the canvas. This is can be used together with cacaserver.
  • CACA_GEOMETRY: set the video display size. The format of this variable must be XxY, with X and Y being integer values. This option currently works with the raw, X11 and GL drivers.
  • CACA_FONT: set the rendered font. The format of this variable is implementation dependent, but since it currently only works with the X11 driver, an X11 font name such as fixed or 5×7 is expected.

That’s all. Have fun with it.

  1. How come when I use the colored version of ascii my video plays fine, but when in black and white i only get half the video converted? Any idea of how i can do this?

    • I guess no one out there knows why I only get half images? :-(

      • try to resize the window if you are using the x11 driver

    • From mplayer’s man page:

      “HINT: You probably have to specify -monitorpixelaspect. Try ‘mplayer -vo aa -monitorpixelaspect 0.5′.”

      This worked for me.

  2. hey there. i have mplayer install on my mac using darwinports, yes, it is the command line version. I also installed aalib and libcaca. when i try both of your commands i get an “error opening/initializing the selected video_out (-vo) device.” when i try opening that same file with the quartz video out it works. im guessing the libraries arent fully compatible or something?

  3. ok so i was trying that with an avi. When i tried it with an mp4, it plays audio, but it says there is no video. also, when i do mplayer -vohelp, it lists the accepted video outputs, aa and caca are not on the list.

  4. This is great! But I have a question. How would I go about saving/encoding the ascii video? I know I could use a screen/video capturing program, but is there a way that I could use Mplayer to save/encode this directly?

  5. It works well when playing in X, but when I go to real terminal (tty1) it plays the movie, but it doesn’t go smooth. The pictures blanks constantly and a whole image of frame is never rendered, only some some parts… wierd

    I tried this on 3 different computers and there is always the same result. :(

  6. hello there grant i got it from a mate so i think this is the site
    and details, they have a deal on at the mo ,just say michael nalsim said you would sort him out

  7. great work, thanks – cacalibs rock the house 8)

Leave a Reply

Site last updated October 20, 2012 @ 12:53 pm; This content last updated September 13, 2012 @ 2:16 am