MPlayer resume script (v2-alpha)

MPlayer logo

A while back I attempted to write a wrapper script for mplayer to resume a file. Unfortunately, that script was rather limiting where:

  • File name must be first entry
  • You have to manually specify the "-profile" parameter
  • You cannot specify a global profile (i.e. the profile you specify only applies to the last file)

Now I have a new script that resolves the above issues! Unfortunately, there are some new issues with the new script:

  • It’s slow at generating command for many files
  • Extension-less file won’t work…
  • Per-file manual profile definition is not yet implemented – though automatic RegExp profile definition is working :-P !
  • This script is very much in the alpha stage and more testing is needed – so use at your own risk!

Sounds cryptic? It’ll be clearer after I’ve shown you some examples.

As with the previous script, an example usage (we’ll assume we’re trying to resume a file called "mediaFile.avi" at timecode 300, and the script is named "mp"):

echo 300 > mediaFile.avi.txt
mp mediaFile.avi

Also as with the previous script, you’ll probably want to enable the "statusline" display by adding "msglevel=statusline=9" into your mplayer config file (at "~/.mplayer/config" | "/etc/mplayer/config"), and ensure "quiet=0".

Now, to use a profile for all files (at the moment, it doesn’t matter where you place "-profile" and "-ss" – they just get applied to every file…):

mp -profile hd file1.avi "file 2.avi"

However, the real magic of the v2 script comes into play when you have multiple files, matching multiple profile switching definitions, with different resume files! For example:

$ ls -d *.avi*
file1.mts
file1.mts.txt
2x03 SomeEpisode.mkv
2x03 SomeEpisode.mkv.txt
file2.avi

$ less mp
...
profiles=(
	# [PF name]	[RegExp]
	"hd"	"(/|^)[0-9]{,2}x[0-9]{,2} .*.mkv$"
	# ---- Generic profiles ----
	".mts"	".mts$"
)
...

$ mp file1.mts "2x03 SomeEpisode.mkv" file2.avi

The script will now use the ".mts" profile for the mts file, the "hd" profile for the .mkv file, the "global" profile for the .avi file, whilst picking the values out of the resume files and resume at the point specified in the .txt files!
(Just in case you’re wondering, the "global" profile is defined in the "$defaultProfile" variable in script.)

Anyway, you can get the script here.

Of course, if anyone’s interested in improving it, they’re more than welcome to do so! Just don’t forget to email me a copy!

Advertisements

3 Responses to “MPlayer resume script (v2-alpha)”

  1. innn Says:

    I don’t know why it’s not working. I use windows xp, if I understand correctly I need only to have unxutils in path also the script the 2 lines enabled in mplayer config, but it does not work,
    I need help, please

  2. innn Says:

    I forgot to provide the error I’m getting , which is:
    “Usage: grep [OPTION]… PATTERN [FILE]…
    Try `grep –help’ for more information.
    >>>> “”C:\mplayer\mplayer.exe”” -profile global “f:\vezi filme\Animatrix.avi.txt””

  3. klo2k Says:

    I have never tested the script out in Windows nor was it ever intended to run on it – brownie points for trying :-) !

    I have actually gone back to creating an alias for mplayer with something simple like:
    alias mp=’mplayer -profile global’
    alias mpp=’mplayer -profile’

    As for profiles, I’ve found the following option which enables me to create a .conf file in the same directory as the video (defined in ~/.mplayer/config) and is read on play:
    use-filedir-conf=1

    So for “video.avi”, the config file would be named “video.avi.conf” and have various settings in it, e.g:
    ——–
    correct-pts=0
    vf=pullup
    profile=global
    ——–

    I suppose now that I’ve gotten used to it, adding a “-ss” isn’t that big a hassle.

    Alternatively, you can always try the PHP mplayer resume script developed by another person:
    http://spaceparanoids.org/downloads/mplayer-resume/


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: