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!

4 comments on “fun with mplayer: on-screen display

  1. olesita

    Hey there,
    Here is an option i`d like to have in osd display but not able to find how to enable it.
    I figure i`ll challenge you 🙂
    can you display timer in hh:mm:sec,ms format? instead of the default hh:mm:sec

    thanks 🙂
    Olesita

    Reply
    1. Steve

      I imagine it’s possible, you’d just need to patch the code to display it using strfttime or whatever it is. I’d ask the mplayer-user mailing list for ideas on how to do it, though.

      Reply
  2. Vadim Bogulean

    Hi,
    I found your post while I was looking for a way to toggle a custom message while playing a video with mplayer.

    In general I’m trying to log in a file current view position of the video so that later on I will use logged info to extract from viewed one interested parts.

    I need to find a way to display a feedback on the screen while registering those parts.
    Example, when interesting section plays, I press a button and I want mplayer to display something like “registering…” and then when pressing again it will remove the message.

    Any Idea?
    Thanks, vadimbo

    Reply

Leave a Reply