Tuesday, February 26, 2008

mplayer-resume for mythvideo

Intro: Ok this is a quickie but a goodie. I have my mythtv box (running ubuntu feisty) connected to my HDTV with a basic VGA cable. Using mythvideo I watch my movies in HD. These HD movies are generally encoded with the h.264 video encoder and AAC audio and the MKV container. In mythvideo I got the best looking playback by opening these MKV files with mplayer. In mythvideo I used the command:
mplayer -fs -zoom -vo xv %s
I navigate and control mythvideo with a pvr-150 remote and LIRC.

The problem: Their is no native feature in mplayer to save the position of a movie when exiting mplayer. So when I'm watching a movie and want to finish it later, I have to start from the beginning and fast-forward through to my last position. Not a huge problem, but easy to fix.

The solution: mplayer-resume. This is a simple shell script that parses the output of mplayer and creates a small text file with the timestamp you left off at (using get_time_pos). The instructions included in the download are very easy to follow, but basically the idea is you paste into your .lircrc file the commands:
begin
prog = mplayer
button = stop
config = get_time_pos
end
begin
prog = mplayer
button = stop
config = get_filename
end
begin
prog = mplayer
button = stop
config = quit
end
Then with the actual script do a:
# cp mplayer-resume /usr/local/bin/
# chmod +x /usr/local/bin/mplayer-resume
And finally in mythvideo instead of using
mplayer -fs -zoom -vo xv %s

use
mplayer-resume -fs -zoom -vo xv %s
One important note: It seems it makes a difference using the actual stop button on the remote versus the back/exit button. You MUST use the actual stop button for the script to work.

Again, check the included instructions for a more detailed explanation of the process, but it was relatively painless and works quite slick. Good luck..