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.
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.