fun with mplayer: save / resume playback script

I must be on a roll. I just got my other big problem with mplayer solved: resuming playback. :)

It turns out that MPlayer has a lot more slave / LIRC events than I knew about, and one of them is ‘get_time_pos’ which prints out the current playback position to stdout. With that, I was able to write a php shell script to save that value to a file, and read it on playback and seek to that position. Pretty cool stuff.

Here’s the script, I’ve added it to my SVN repository for bend: http://spaceparanoids.org/trac/bend/wiki/mplayer-resume

Right now the only problem it has is that it’s PHP5 dependent, and only then because I use file_put_contents() and file_get_contents(). I haven’t been using PHP4 for a long time, so I was too lazy to make it backwards compatible, but I’ll fix it later.

I’ve documented how to use it in the script, so everything is already covered there. I’ve been testing it and it works great. Now I can seek chapters on my video files and leave and come back anytime I want. I’m pretty excited about that. :)

Leave a Reply