… and red, black and white interference. unichrome via cle266 graphics.

Today with the help of Reimar Döffinger I finally got around to be able to use mplayer http://www.mplayerhq.hu/ in X11.

I think I’ve been using this box for several years and always switched to the console in order to be able to watch a video — cvidix (console vidix) had been working fine all along. The next thing I’ll attempt is to compile this mplayer for firefox plugin, I guess.

(The next thing that happened wasn’t me compiling mozilla plugins, but that I typed out my entry and then tried to run mplayer -vo gl mf://*.jpg which resulted in a total system freeze and loss of entry. Thanks mplayer! Bah.)

To get mplayer working on X11, the first thing I needed to do was to install the svgalib http://www.svgalib.org/ kernel helper module as is briefly mentioned in the mplayer docs at http://www.mplayerhq.hu/DOCS/HTML/en/output-trad.html#vidix

After downloading and compiling the svgalib_helper, after a modprobe svgalib_helper and make device in the svgalib-1.9.*/kernel/svgalib_helper directory as well as moving the svgalib_helper dir into the mplayer source and recompiling the vidix drivers I was set up.

Now I could run mplayer with xvidix, but all I’d get would be a green window without video!

So I jumped in the #mplayer irc channel where reimar told me about -nocolorkey. This was indeed the solution: mplayer -vo xvidix -nocolorkey mymovie.avi and I could see the video playing. Yay!

Unfortunately, that’s where the real trouble started. The movie had strange horizontal interference lines flickering over it coloured red, black and white — approximately two to three centimetres in width and four pixels thick, with each ten pixels in between.

Additionally, mplayer corrupted my X background, leaving black and white miniaturised shadow copies of the movie on my background even after mplayer had ended.

Turns out my X and mplayer decided to share the same video ram, so the flickering on the movie was some other X program drawing in the memory where mplayer was trying to play the movie. This also explains the corrupted background.

The mplayer docs mention reducing your video ram in the xorg.conf file by four megabyte. My card is using 64 MB (shared), so I added a VideoRam 60416 to my xorg.conf. I also tried setting Option "XaaNoPixmapCache" — but nothing would help, the corruption persisted.

I asked reimar for help again, and he found out that the vidix driver for my card writes at 6 MB - regardless how much ram the card is really occupying. Trying to set the VideoRam to 6144 KB however, was ignored by X and it proceeded to use all 64 MB.

Here’s a patch:

Index: unichrome_vid.c
--- unichrome_vid.c (revision 20515)
+++ unichrome_vid.c (working copy)
@@ -78,8 +78,9 @@
 #define UC_MAP_V1_FIFO_CONTROL(depth, pre_thr, thr) \
     (((depth)-1) | ((thr) << 8) | ((pre_thr) << 24))
-#define FRAMEBUFFER_START  0x600000
-#define FRAMEBUFFER_SIZE   0x200000
+#define VIDEOMEMORY_SIZE       (64 * 1024 * 1024)
+#define FRAMEBUFFER_SIZE       0x200000
 FILE *logfile = 0;
@@ -529,7 +530,7 @@
 vixInit (void)
   long tmp;
-  uc_mem = map_phys_mem (pci_info.base0, 0x800000);
+  uc_mem = map_phys_mem (pci_info.base0, VIDEOMEMORY_SIZE);
   enable_app_io ();
   outb (0x2f, 0x3c4);
@@ -590,7 +591,7 @@
   outb (mclk_save[2], 0x3c5);
   disable_app_io ();
-  unmap_phys_mem (uc_mem, 0x800000);
+  unmap_phys_mem (uc_mem, VIDEOMEMORY_SIZE);
   unmap_phys_mem (vio, 0x1000);

Replace 64 with your actual amount of memory. The vidix driver will write to the last 2 MB.

I’m now running my xorg.conf with VideoRam 60416 and everything works nicely. I’ve put the following commands in my system startup script:

modprobe svgalib_helper
rm -f /dev/svga /dev/svga?
mknod -m 666 /dev/svga c $SVGALIB_HELPER_MAJOR 0
mknod -m 666 /dev/svga1 c $SVGALIB_HELPER_MAJOR 1
mknod -m 666 /dev/svga2 c $SVGALIB_HELPER_MAJOR 2
mknod -m 666 /dev/svga3 c $SVGALIB_HELPER_MAJOR 3
mknod -m 666 /dev/svga4 c $SVGALIB_HELPER_MAJOR 4

Bonus: you can have a movie playing on your console background using

mplayer -vo cvidix -colorkey 0 -nofs mymovie.avi

Unfortunately I don’t know how to stretch the movie to full screen (-fs will disable the effect)

More Bonus: If you want to play a video on console and it does not fit to your monitor aspect ratio, you are faced with console text showing through at the top and bottom of the screen:

| ugly console text|
|                  |
|     video here   |
|                  |
|more console text |

One way to get a blank screen for playing videos is like this:

setterm -cursor off >/dev/tty9
mplayer -vo cvidix -fs mymovie.avi </dev/tty9

Then switch to vc9 (<Alt>+<F9>).