MPlayer and Openbox

Edit: Unfortunately, the images originally included in this post are gone, because of hosting problems in late 2009. My apologies.

There are probably a dozen video players for Linux, with another dozen apiece in frontends you can use to run them. Multiply that by the half-dozen more in codecs and stream decoders and whatnot, and there’s the formula to somehow jerry-rig an entertainment package for Linux.

It gets crazy after a while. I’ve heard of installing upwards of six or seven packages, plus their dependencies, just to open a file with Totem. Not that Totem is at fault for that — it’s just the way things are.

I’m firmly planted in the MPlayer contingency though. It’s odd, since I would be willing to describe myself as a Rabid Fan, but I haven’t added it to my software page. Who’s in charge around here, anyway?

Regardless, as far as I’m concerned, MPlayer is the way to go for Linux video playback. However, I like my MPlayer to behave in a certain way, and not to do certain things. Here’s what I mean:

Ain’t that a beauty? Free-floating, undecorated, always on the top and on every desktop, with a single black one-pixel border. No space lost to unnecessary frivolities, and the action doesn’t stop if I roll to a different desktop. Best of all, you can run that against the Openbox window manager on machines as slow as 300Mhz, and provided the video card doesn’t balk at the chore, pump that up to a fullscreen image with the single press of a key.

Here are some settings, if you want to do that in Openbox, which is also known as The World’s Finest Window Manager. To some it is, anyway. šŸ™„ There may be other ways to tackle these problems; if there are, let me know about them. …

First, make a small decision: Do you want that free-floating always-on-top movie screen to keep a thin 1-pixel border or not? The benefit in the border is that you have something (albeit tiny) to grab if you need to resize the window. If you can see yourself stretching the image to suit the screen, you might want to keep it.

However, it sticks around on my machine when I punch the “F” key and blow the image up to fullscreen. So I get a queer gray one-pixel border along the left and top sides of the screen, where the border is being drawn. Irritating!

The setting for that choice is under “Appearance” in ObConf, as the checkmark for “Windows retain a border when undecorated.” Choose wisely, but this is an easy thing to turn off or on. If you need that for a short second or two, turn it on then turn it off. No guilt.

Next, undecorating that window and sticking it to the topmost layer each time you open a movie is also Irritating!. So let’s set MPlayer to always open undecorated, and stuck. Here’s the important part of the $HOME/.config/openbox/rc.xml file that will do that.

<application name="xv" class="MPlayer">

(Note that I hunted down the values for the name and class variables for you. You’re welcome.) Stick that in the applications section of your rc.xml file, and every time MPlayer opens, it will follow those rules.

(You can also preset the X and Y coordinates of the window, and I’ve tried that, but it wasn’t to my liking. I like to position the movie right where you see it there, in the lower right corner of the screen. But each movie has different dimensions depending on the DVD, and so presetting the location sometimes threw the movie off the screen. That meant I ended up moving it anyway, so I might as well just move it the first time, one time. Maybe that makes sense, maybe not.)

A couple of related tips: First, on my Crux system (and on another distro which I can’t remember now), MPlayer didn’t make a point of blocking xscreensaver or the DPMS BlankTime and OffTime settings. Which means if I stop working and just watch the movie, and don’t touch the mouse or the keyboard at all, after about 10 minutes the LCD shuts off, or xscreensaver kicks in.

That too is Irritating!. Therefore, it is necessary to either recompile MPlayer manually (I think) to preset that option (ack! recompile!), or feed it that option in the command line, each time you start it. Rather than recompile, and rather than type

mplayer -stop-xscreensaver mymovie.ogv

at the terminal prompt each time you watch a movie, just add this line to your bash profile … wherever it may be:

alias mplayer="mplayer -stop-xscreensaver"

Log out, log in and it should take effect. Thereafter you can just type “mplayer” and the filename and that alias should do the rest.

One similar point for users of emelfm2 or other file managers, who can right-click on a video file and select a program to open it with. … Edit the filetype for movie files, and add that flag to the MPlayer command option. Works like a charm, and the screen doesn’t go black when Fonzie jumps over the shark.

Finally, and this is really only for people who work on compile-it-yourself distros … don’t forget to compile alsa (assuming you use it) before you compile MPlayer. MPlayer is generally smart enough to check and see if you have alsa on your system before it compiles, and if you don’t, you’ll have no audio playback on your machine. Your sound will work fine, but MPlayer will think you don’t have an audio option, and ignore your attempts to hear Fonzie jump that shark. Silly mistake, huh? Yeah, I’ve done that. šŸ™„

That’s it. Enjoy the rest of the film. šŸ™‚


6 thoughts on “MPlayer and Openbox

  1. dave foster

    Thanks – I had always wanted to set that up but never bothered to do so. Just a note, on my system, the name is “x11” and not “xv”. I got that by xprop | grep CLASS on the mplayer window, perhaps I got lucky.. the name/class thing is always confusing.

  2. robert

    Wow, so much work for such simple things. In VLC I can do this with mouse clicks under the ‘view’ menu. VLC, in all operating systems, is the best!

  3. reacocard

    For the xscreensaver bit, you can always just put


    into ~/.mplayer/config instead. This works for any mplayer command line argument (i think), so you can preset mplayer pretty much however you want with it.

    And yes, VLC subtitling sucks. Mplayer’s is good bvy default, but to make it even better add these line to ~/.mplayer/config


    The first two lines set the text size to a more reasonable level. The remainder increase the quality of font rendering, giving you beautifully smooth subtitles.

    Other tricks you can try are

    Set default audio/sub language:


    Those lines choose japanese audio if available (useful for watching anime :D), and fall back to english if it isnt (or the default in the file if neither). Subs will be automatically enabled if english subs are available, otherwise they are disabled.

    Up software volume max for computers with poor speakers (use 9 and 0 keys to adjust softvol):


  4. K.Mandla Post author

    dave foster: Ah, you’re right: I forgot that those values could change slightly from distro to distro, thanks.

    robert: Sorry, but I’m afraid you’ll never sell me on VLC. I have friends who love it, but it doesn’t seem to do what I want, how I want. To each his own, I guess. … šŸ™‚

    reacocard: Thanks for those, I have been wanting to set some of those things up properly in the config file. To be completely honest, I hadn’t dug around for them yet because the documentation for MPlayer is … intimidating. šŸ˜Æ Cheers!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s