MPlayer Tools

Powered by:
SourceForge.net Logo


The main purpose of this package is to ease you the use of MPlayer.
The sofware package focuses on five different areas:
  1. mcatcher
  2. Graphical User Interface (MPlayer GUI Frontend)
  3. TV utilities
  4. Subtitle manipulations
  5. Statistical tools
  6. Final notes
1) mcatcher

The scripts automatically save the movie you are watching and next time start mplayer with the same movie from the saved position using a tiny `cdm;mstart' command.

Available commands

How it works
The mcatcher wrapper script analses mplayer's output to determine the current file being played and the current movie position. The filename is saved into ~/.mplayer/mcatcher.save the position into an mplayer .conf file next to the movie or into your ~/.mplayer directory. The script decides to save the movie position on exit only if you watch the movie continuously for 12 mins (this value is configurable in the config file) or if you run the msave utility. The script signals that it will save the movie position with a message to stdout and with a flashing Scroll Lock led action using `xset led 3' commands. It also signals that A-V sync is broken with a continuously turned on Scroll Lock led.

The mcatcher logfile
The mcatcher log file (~/.mplayer/mcatcher.log):
mcatcher logs every movie you watched. File format:
   mplayer startup datetime|playtime|filename
You are free to delete any line at any time but be aware that mlists (cds) and mlistd (cdd) uses this file to determine directories and episodes; mstart/mplay and the GUI uses it to determine which movie was not yet started.
If File::Spec::Link is installed then symlinks are resolved in the filename.

The mcatcher config file
The config file (~/.mplayer/mcatcher.conf) contains conditions, commands and assignments.
Lines beginning with # are comments.
You can also append values using the ,= operator for example like this:
   option af,=extrastereo=-1
   option af,=equalizer=4:3:3:0:-3:-3:0:1:2:3
Any assignment may contain objects (anything that mhelp prints out) like this:
   option sub=subs/%file%.srt
The assignments may contain replacements of the form: #replace#subject#search_term#replacement_string# where the subject can contain objects and the search_term is a perl regex; for example:
   option sub=subs/#replace#%file%#.avi#.srt#
See a sample configuration file in the package.
Beside the main config file you can have a directory level config file called .mcatcher.conf which will be used for every file in that directory or a file level config file. If your movie is called movie.avi then the file level config file must be called movie.avi.mconf

Commands and assignments

Conditions
You can use conditions in the configuration file to set different commands or assignments.
These looks like this:
   [subject regex]
or:
   [hash(value) regex]
If the regex matches the subject the condition will evaluate to true and the commands and/or assignments before the [end] keyword will be evaluated.
As an example let's see how you can use the softsleep if the RTC is already in use:
   [lsof /dev/rtc]
      option nortc
      option softsleep
   [end]
You can also have if - elsif - else - end statements like this:
   [filetype stream]
      option cache=1024
   [dir ^/tmp]
      option nocache
   [else]
      option cache=8192
   [end]
Of course you can have as many branches as you want and the [else] part is optional.
And finally you can use the AND and OR operators in one condition like this:
   [file ^Video-\d+-\d+(_\d+)?\.avi$] or [filetype audio]
      noseries
   [end]
Please note that:
  AND has higher priority like in the programming languages.
  Conditions are evaluated only until they are needed as in C. For example if you have [something1] AND [something2] and something1 evaluates to false then something2 will not be evaluated.
mstart will identify modes written in this way:
   [mode mkv]
      option lavdopts=skiploopfilter=all
      option framedrop
   [end]
Your mode definitions can overlap and can be extremely complex but if you use this form then
   mstart mkv file.mkv
will turn on the decoding optimizations for you if you have a slow machine.
The command line above is equivalent to:
   mplayer -lavdopts skiploopfilter=all -framedrop file.mkv

Hashes

Subjects

Movie series detection
The detection is based on filenames.
The filename must be formatted like this (the parts in [ ] are optional):
name [-] episode [anything].avi
Examples:
Desperate Housewives - 1x15 - Impossible.avi
Friends 312 - TOW All the Jealousy.avi
Stargate.SG1.S09E06.Beachhead.avi

The name of the TV show will be converted to lowercase and every whitespaces, underscores, dots and dashes will be converted to space.
If you have series in other (reasonable) format mail me!

Series detection on DVDs can be a lot more tricky. It is a new and untested option in mcatcher, I may even remove it if I find it unusable. It is based on the assumption that the DVDs are enumerated. The series name will be the disk label. The episode will be disk label/track, but if the label contains underscores only the last part will be used, for example if you have a disk labeled ROME_D1 an episode will be D1/3. Also, please note that detecting the dvd device to read the disk label may not work correctly. If it does not work for you please drop me a mail.

Optional perl modules
You can get them from CPAN but your distribution may also ship them.
In paranthesis you will find the package name in which ubuntu/debian ships the module (except for Sys::Proctitle which is currently not shipped).

Optional programs

2) Graphical User Interface (MPlayer GUI Frontend)
MPlayer Tools has a nice GUI written in PerlQT. It is not as effective as the command line interface (GUIs never are) but it is pretty self-explanatory. That is why my documentation about the GUI is short.
You have to know that the GUI is nothing more then an interconnection between some interfaces. mgui does the playlist management, the rest of the workload is done by mcatcher.

The main window
The upper black part of the main window is like a display, the movie's title and properties go there.
The row below contains the same informations mcatcher displays in player mode. In addition you can see an A-V box. If it is not 0.0 then the video and audio are out of sync. If it is not moving toward 0 and the CPU stays on 1.00 (or 0.50 or more on a dual core system) means that your system is not fast enough to play the movie.
The top scrollbar shows the current position in the movie, you can drag it. The bottom scrollbar shows the volume.
The buttons on the bottom of the main window do exactly the things that are written on them.

There are a few hidden clicks that you should know about.

The playlist
I assume everybody knows what a playlist is. What you should know is that QListBox does not support playlist reordering by dragging (it selects on drag) so as a workaround there are two small buttons on the right-bottom corner of the playlist which moves the selected files up and down.
The playlist has 4 more buttons: Options
Known issues
No bug reports about these issues please (only if you know a workaround), I will solve them as soon as PerlQT offers a solution (probably when QT4 support arrives, only God knows when will that be... )

3) TV utilities
MPlayer has built-in v4l capabilities however I find it uncomfortable to use them.
So here is a set of programs to make it easier.

Available commands Recommended minimal lirc configuration
I recommend the following minimal lirc configuration. You can put them for example in your ~/.lircrc file.
You may need to change the button names as this configuration was created for my remote.
begin
    button = REC
    prog   = mplayer
    config = run tvrecord\nquit
end
begin
    button = TIMESHIFT
    prog   = mplayer
    config = run tvtimeshift\nquit
end
begin
    button = STOP
    prog   = mplayer
    config = run "killall -q -INT tvtimeshift tvrecord mloop"\nquit
end
begin
    button = DISPLAY
    prog   = mplayer
    config = run "tvtsinfo -q"
end
begin
    button = ENTER
    prog   = mplayer
    config = run "tvconf xosd"
end
begin
    button = VOL_UP
    prog   = mplayer
    config = run "tvvolume +"
end
begin
    button = VOL_DOWN
    prog   = mplayer
    config = run "tvvolume -"
end
begin
    button = SNAPSHOT
    prog   = mplayer
    config = screenshot\nosd_show_text ">>> SCREENSHOT"
end
begin
    button = BOSS_KEY
    prog   = mplayer
    config = run "mcounter;xset dpms force standby;xset +dpms"\npause
    config = seek -10\nrun "xset dpms force on;xset -dpms;killall -q -HUP mcounter"
end
Please refer to lirc documentation (http://www.lirc.org/) if you don't know what these lines mean.
Of course this is very basic, you might also want to put another config=volume +1 and config=volume -1 entries with a different buttons or in a different mode.

Configuration Options
(to use with tvconf): 4) Subtitle manipulation scripts
5) Statistical tools

5) Final notes
At first the mcatcher.conf file may seem complicated. See a sample file in the doc/ directory. The config file is not compatible with versions <=5.2 that is why it has been renamed.
mplayer-tools <=5.2 used to have options to start the X server automatically if it isn't already running for both mcatcher and tv.
This has been removed starting from verion 6.0 since nowadays every distribution ships their linux with an X display manager so probably no one would use the option anyway.
Version 6.0 also introduces conditions in the config file and dynamically loadable modules from the mplayer-tools library.
If you find any bugs (which you probably will) or have any ideas regarding to the package, do not hesitate to contact me. My email address can be found in the AUTHORS file in the package.


mplayer-tools © 2009 Sos Gergely
mplayer-tools comes with ABSOLUTELY NO WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This is free software, and you are welcome to redistribute it under certain conditions. See the GNU General Public License for more details.