Aalib, caca

From Helpful
Jump to navigation Jump to search
These are primarily notes
It won't be complete in any sense.
It exists to contain fragments of useful information.

aalib

[1]

Tweaking for nicer results: http://aa-project.sourceforge.net/tune/


aview

Aview itself takes p[ngbp]m files For a wrapper to view most images, try a script like:

#!/bin/bash
for fn in $@; do
  echo $fn
  convert $fn /tmp/aview-wrap.tmp.ppm ||exit
  aview -dim -bold -normal -reverse -boldfont -error_distribution -minwidth 130 -minheight 130 /tmp/aview-wrap.tmp.ppm
done;

...but there is an asciiview that does exactly that (though it doesn't seem to take all the options aview does)

caca / libcaca

Colour AsCii Art library

[2]



...in mplayer

mplayer has -vo aa and -vo caca

-vo aa:

  • has a few options (see the man page)
  • aa doesn't really understand aspect ratios. If you see only a thin strip, you want to specify -monitorpixelaspect, usually with a value around 0.5 (but experiment per video, particularly if you want it to be exactly screen-filling for the given console/shell size. So far all my values were within 0.35..1.3, most around 0.5)
  • depending on console/shell/font, -vo aa:driver=ncurses may look better - or worse.
other options that may help, or break things.
  • You get extra key bindings: (contrast is probably the most interesting of them)
1 : contrast -
2 : contrast +
3 : brightness -
4 : brightness +
5 : fast rendering          (seems to conflict with hue?)
6 : dithering               (seems to conflict with hue?)
7 : invert image            (seems to conflict with saturation?) 
a : toggles between aa and mplayer control

-vo caca

  • needs tweaking to look decent
  • most tweaking via environment variables.


Notes:

  • subtitles seem to just get in the way, and won't be readable anyway.
Try -nosub -noautosub
  • increased contrast makes for more crisp, more black and white video.
e.g. -contrast 25 though best values will vary per video
  • If you want to run this in an open shell, then you don't want X so use DISPLAY= (with no value) as in the example below
since that means you're outputting to the shell you run on, you then also want to avoid flicker from the other output, so:
-quiet to suppress most stdout messages
2>/dev/null to hide stderr warnings/errors
  • IF you want to run mplayer in an X terminal window with a small font size, one way is:
  • If you're loading the CPU a lot (very small font size, or whatnot), you might want
-framedrop
size down the video before it's handed to aa/caca


Examples:

# same shell
DISPLAY= mplayer -vo aa -monitorpixelaspect 0.5 -nosub -noautosub -quiet -framedrop \
  -contrast 25 videofile  2>/dev/null

# small-fonted X window. A simpler term is usually faster than the now-often-common-alpha-blended-and-whatnot one
xterm -fn 5x7 -geometry 250x100 -e "unset DISPLAY;mplayer -quiet -vo caca -monitoraspect 1.3 videofile"

# For capture from a webcam, you might want something like:
# (higher resolution than ~320x200 is usually slower or wasting CPU)
mplayer -quiet    -tv driver=v4l2:width=320:height=200 tv://


Note that all this ignores a bunch of the output alternatives offered. I've yet to really experiment with them.