fun with mplayer: on-screen display

Yes, it’s time for another exciting episode of “Will Steve Ever Stop Tweaking?” I think we all know the answer to that one by now.

Anyway, now that my main problems are out of the way, I’m onto playing with other cool features that I never really cared about since my PVR wasn’t living up to my extreme level of standards. This time, I’ve been fooling around with LIRC. The reason is because I use an all-in-one remote that controls everything (TV, receiver, MythTV, DVD player and VCR) and it has a lot of buttons on it.

One of the buttons it has on there is an “Info” button. I thought it would be nice to setup the OSD (on-screen display) to tell me how far along in the media file I am when I pushed that little button. So, I did some research and it’s really not that hard.

First of all, you need to pick a font to use for the display. By default, mine didn’t have one and I was getting an error that said “osd text out of range” and all I would see was the Play button. The mplayer docs tell you to just pick a TrueType font to use, and then pass it in the CLI arguments. In their example, they use arial.ttf though I imagine you can use whatever one you like.

I ran locate arial.ttf and only came up with one hit from the corefonts package located at /usr/share/fonts/corefonts/arial.ttf. I fired up mplayer with that as the option, mplayer -font /usr/share/fonts/corefonts/arial.ttf movie.mkv and pressed the ‘o’ key to toggle OSD output, and it worked that time. :)

I don’t like passing CLI arguments, though, especially when I can cram them all in my ~/.mplayer/config file. So just add font=/usr/share/font/foo.ttf and you’ll be done with that.  Next up is configuring LIRC to display that stuff. We’ll be playing with buttons, so be sure to wash your hands for this step.

Looking at the mplayer docs again says that there are four OSD levels. The default is 0, none. You can play with them to see which one you like by hitting ‘o’ and cycling through the options, or just running -osdlevel as an argument. Myself, I like #3, “volume bar + seek bar + timer + total duration of media” so that’s what I want to set it to display in my config.

Using the slave commands as a reference, which also act as LIRC events (see ‘mplayer -input cmdlist’ for a shortened version), you can see that osd [level] will turn on the display.
Open up ~/.lircrc/ and add an entry for the button you are pushing to display your preferred OSD level:

begin
prog = mplayer
button = green
config = osd 3
end

After I did that, though I realized there was one little problem. The display doesn’t go away. That’s easy enough to fix, though. As I discovered yesterday, if you put *another* config line after that one, then LIRC will cycle through those options. So, to turn it back off, just add another line telling it to reset back to 0. The end result would look like this:

begin
prog = mplayer
button = green
config = osd 3
config = osd 0
end

And there you go. Now you can have a pretty OSD telling you the current playback position and the time left in your favorite show with the flick of a button. Love is all around, baby!

Leave a Reply