The main purpose of this package is to ease you the use of MPlayer. The sofware package focuses on four different areas:
1)
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. You don't even have to
start the X server yourself. And there is more.
Available commands:
mplayer - at install mplayer-tools overrides the mplayer command,
the new command starts the mcatcher utility and then it calls
the original mplayer to play the movie. If you have no running
X server, then it starts one and plays the movie on it
(if there is a running X server, it uses that one)
mstart - 1) if you give parameters for mstart will behave like the mplayer command
except that it will force the position saving of the movie you start. (Otherwise
the movie position will be saved only if you watch the movie for more then 12 mins
or whatever is set into MCATCHER_MINTIME.)
2) if the first parameter is `all' the behaviour described above is changed:
mstart will pass along only the files which are not yet played. This means that you can
watch a list of movies but you can start mplayer with the very same command every time. Ex:
mplay all 1.avi 2.avi 3.avi 4.avi
No matter how many times you quit the command will resume like if the four files
were only one stream. If no files are specified (only `mplay all') mstart works with all
media files from the current directory.
You can use the -shuffle mplayer option to play the files in random order but in this case
the playback will not be continued with the file you stopped.
3) without parameters mstart will start the first movie saved into ~/.mplayer/currentmovie
but only movies from the current directory. If there are no movies saved from the current
directory mstart will start the first movie from the current firectory in lexical order
which was not watched yet (according to the mcatcher logfile).
This description may sound confusig, but take a look at the following example:
Let's say you have two files:
/mnt/moviepartition/Movie 1/Movie CD1.avi
/mnt/moviepartition/Movie 1/Movie CD2.avi
If you type the following commands:
cd /mnt/moviepartition/Movie\ 1/
mstart
you will watch the movie called "Movie CD1.avi". But let's say you don't have time to
finish the movie, so you exit mplayer and stop your computer. Then you start it again,
and you type the following commands:
cdm
mstart
and "Movie CD1.avi" will continue. Now let's say "Movie CD1.avi" terminates. The next
mstart command (without any parameters) will start "Movie CD2.avi" if you are in the
/mnt/moviepartition/Movie 1/ directory.
And what's even cooler is that you can say:
cdm
mstart all
every time when you want to continue watching the two files and you don't have to type
another mstart command if "Movie CD1.avi" terminates (you don't have to stand up :-) )
Hopefully you will find this clear and comfortable enough.
mplay - This is an alias to mstart but it starts the mcatcher utility
in Player Mode. In this mode mplayer's output is supressed
and a more reticent output is displayed:
[FLAGS] POS [LENGTH] REMAIN [BUFLEVEL]
FLAGS are:
S - mcatcher will save position
P - movie is paused
B - A-V sync is broked
Just try it and you will understand it. Be aware that Player Mode will not
work properly if you use the `quiet' or `really-quiet' mplayer options.
mswitch - switches between Player Mode/normal display in the current terminal, except if you call
mplayer via mplay. It does NOT work with mc! You have to use it before you start mc.
cdm - cd into the current movie's directory
the scripts can save any number of movies
you can type a number after the command
Ex: cdm 1 changes to the second movie but it also moves the
movie into the first position so mstart will start this movie
mlist - lists all the saved movies and the associated numbers you can use with the cdm command.
mlists - lists your movie series, the number of watched episodes, the last episodes,
and (if you still have it in your mcatcher log file) the directories containing movie series.
you can type a regex to narrow the listing, ex: mlists Desperate Housewives
but saying "mlists despe" will probably do the same thing.
cds - this is a wrapper to mlists. The last directory is not displayed but cd into.
ex: "cds despe" will change directory to Desperate Housewives
a simple cds without parameters will go to the last watched show.
setxlayout - set the ServerLayout for xmplayer (by manipulating the environment)
Server Layouts can be configured in your X config file.
edit /etc/profile.d/mplayer-tools.sh to change the value permanently.
The special value "off" disables xmplayer.
msave - force position saving of the currently played movie.
Put the following line in your ~/.mplayer/input.conf file:
KP_ENTER run "msave"
This way you will be able to force the position saving with a single keypress.
mcancel - cancels any running timeouts and disables the position saving of the movies being
watched. Once you give this command no movie positions will be saved by the running
mcacther scripts except if you explicitely force it by an msave command.
Maybe you want to put a line like
ESC run "mcancel"
into your input.conf file.
mdisable - disable mcatcher temporarily only on the current terminal.
When mcatcher is disabled the regex and shortcut options are still available
and the mplayeropts will still be passed for the existing movie series
but no new movie series will be detected.
menable - enable mcatcher temporarily only on the current terminal.
mstrip - strips the mcatcher logfile. You might want to run this periodically if you use
maxloglines=0 in the mcatcher config file, maybe from a cron job.
It's options are described under the mcatcher config file, global section.
You can give a directory as parameter. mstrip will remove every entry from
the logfile from that directory but not from it's subdirectories. This is useful
if you use mplay or mstart to watch every file from a directory, and you want to
watch all of them again.
Internal commands (use them only if you know what you are doing): mcatcher - this is the wrapper script that saves the movie position.
Using this from command line makes sense if you want to play
an audio file and you have no X server running and an audio file
does not need one but the mplayer command would start it. But note that
setxlayout off
has the same effect.
xmplayer - also a wrapper but you can call it yourself too
starts an X server without a window manager and starts playing the movie on it.
Use it if you are already running an X server but for some reason
you want the movie to be started on a new X server.
mgetdir - for internal use. cdm calls it.
Call it from the command line if you don't want to change directory
but you want to clean ~/.mplayer/currentmovie from a deleted entry.
The msave command sends an ALRM signal to every instance of mcatcher. If there is no mcatcher running it sets the environment signalling to the next mcatcher that it has to save the movie position no matter how long you watch the movie. The menable and mdisable also operates the environment. Be aware that the environment `signalling' WILL NOT WORK OVER TERMINALS. The mcatcher wrapper script analyses mplayer's output to determine the current file being played and the current movie position. The filename is saved into ~/.mplayer/currentmovie 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 /etc/profile.d/mplayer-tools.sh) 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. MPlayer states the End Of File condition only on exit so if you play more media files with video streams from a single mplayer command you will need the -identify mplayer option for mcatcher so mcatcher can determine the movie's length and can determine whether you finished the movie. For example: mplayer -identify MovieCD1.avi MovieCD2.avi The audio-only files does not need the identify option.
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 (and cds)
uses this file to determine directories, mcatcher uses it to detect movie series
and mstart/mplay uses it to determine which movie was not started yet.
The mcatcher config file (~/.mplayer/mcatcher):
i) the [global] section:
banneddirs a list of directories (separated by :) where mcatcher prefers not to save movie .conf files
this is useful if don't want other people to see your conf file or if you have a directory
in your memory (like /dev/shm) where you copied a movie and you don't want to loose
the .conf file across a restart (remount). The .conf files will also not be saved in any
subdirectory i.e. if you set banneddirs=/ every .conf file will be saved into ~/.mplayer
maxloglines max how many lines to store in the logfile. 0 means infinite and it is somewhat faster but
you will have to clean the logfile either yourself or with mstrip because it will grow.
mcatcher uses a minimum of 10 loglines.
regex example:
regex \.mp3$=-af equalizer=4:0:3:0:-3:-3:0:1:2:3
regex ^(http|ftp|smb):=-cache 1024
if a movie name matches this regex the options after the first `=' are passed to mplayer
Be aware that all regex-es are evaluated for a movie, mcatcher doesn't stop after the first match
noseries example:
noseries1=^Video-\d+-\d+(\d+)?\.avi$
noseries2=^verycommonmovie_name
You have to specify a decimal even if you have only one noseries option.
The movies matching any of these options will never be treated as an episode.
For example the first one matches the files created by tvrecord and it is added
to the config file by default.
shortcut You can configure shortcuts for some files or livestream so you can start them without
remembering their complete path/name. Example: if you put the following line in the config file:
shortcut 1.fm=http://212.72.186.10:8050
then typing the command:
mplayer 1.fm
will start "mplayer http://212.72.186.10:8050"
term_width Set it to the number of columns of your terminal. If you have installed the Curses perl module
this can be autodetected. The default value is the standard 80 chars.
dcop_width Set it to have max length for the kde window titles (using DCOP)
If unset or less than 2 mcatcher uses unlimited.
disable_led Set this option to 1 if you don't want any led action (maybe conserving some CPU time) when
mcatcher states that it will save the movie position or when it signals the broken A/V sync
pos_adjustment
MPlayer cannot pinpoint the exact position in every types of movies so to make sure that
when you restart a movie the playback will continue from a point you already saw mcatcher
saves the current position minus 10 sec by default. This may also help you remember the movie
but if bothers you, set this value to 0. The default is -10 but you can set it to anything i.e.:
pos_adjustment=-0.1 -to go backward just a tiny bit
pos_adjustment=-60 -if you need a few seconds to remember the movie
pos_adjustment=10 -to go forward in the movie (I don't see the point to use this but who knows)
pos_adjustment=0 -disable this feature
osdfont
osdcolor color and font passed to osd_cat (to display msave,mcancel,mcounter).
Try xlsfonts. Default values are lightgreen,-misc-fixed-medium-r-normal--32-0-100-100-c-0-iso8859-1 osd_timeout Set the timeout for osd messages produced by mcatcher and mcounter.
Set it to 0 to disable them completely. Note that mcounter's osd output cannot be disabled,
it will use the default value (which is 5 sec) if you try to disable it.
rem_timeout On the second launch of msave, mcatcher displays how many time remains from the current file
(or the current position if mcatcher is unable to determine the movie's length, try putting
identify=yes in your mplayer config file). This option sets the timeout while this is displayed.
The default is 5 sec, set it to 0 to disable this feature.
mstrip_* These are options used by the mstrip utility (evaluated in the order they are listed here):
removeinexistent - values are 1 or 0. If it's 1 then every movie that is deleted is also
removed from the log file. It's 0 (missing from the file) by default.
minlength - any entry shorter than this (playtime) will be removed from the log.
It's 60 (seconds) by default.
lastepisode - values are 1 or 0. If it's 1 then for every movie series found
in config file mstrip will keep only the last watched episode.
This way cds will still work correctly. It's 0 by default.
It is 0 by default so mstart/mplay will also work correctly.
gather - values are 1 or 0. If it's 1 then mstrip gathers all the entries describing
the same movie into one entry with the last date and with the summarized length.
It's 1 by default.
maxsize - the maximal size of the logfile in kilobytes. The default is 1 megabytes (1024).
Note that the mstrip options appear in the config file like this: mstrip_maxsize
ii)all the other sections:
These are sections for movie series. Every one of them has three options:
episodelist the episodes you already watched (mcatcher puts them there)
display mcatcher guesses the name of the series based on the filename.
You can override it with this option.
mplayeropts options to pass to mplayer.
mcatcher puts a default one when it creates the section, you might want to edit it.
Note that any other (invalid) options in every section is also preserved (but not used or complained about).
MOVIE SERIES DETECTION:
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
If you have series in other (reasonable) format mail me!
If you play a file in this format mcatcher checks you log file if you have already watched a movie
with the same name but with different episode. If you did then mcatcher creates the section for the movie.
OPTIONAL PERL MODULES (you can get them from CPAN):
Curses
-download and install it if you use the PlayerMode and you change your terminal's size.
If installed mcatcher autodetects the size at every startup so you don't have to
edit the term_width option every time you change your terminal's width.
The Curses module is also used by the moviesizes script.
Sys::Proctitle
-if you install it mcatcher will set it's proctitle to the currently played movie
and hides the ugly parameter list. You can see this with a command like this:
ps -Af|grep mcatcher:|grep -v grep
or the apposite `cmdline' file in the proc filesystem.
Time::HiRes
-the moviesizes script estimates how much time it has left before it finishes it's job.
Download and install this module so that this estimation will be more precise.
2)
MPlayer has built-in v4l capabilities however I find it uncomfortable to use them.
So here it is a set of programs to make it easier:
tv - Start the TV Player.
Use the option --tune or -t while you are searching for channels.
This option disables setting the channel names from your already existing
channel list file and disables tvconf's channel related options.
In every other cases the parameters are considered as a TV channel name.
If the script find a channel with this name, starts it, otherwise the parameters
are evaluated as a regex to find the TV channel you want to watch.
If the parameter list starts with -s or --set only the channel is set but there will
be no playback. This is useful to set the channel for a teletext browser like alevt.
Ex: tv -s rtl klub && alevt
tvcancel - Force the scripts to abort immediately
This is for emergencies if something goes wrong.
tvserver - A really simple TV server for only one client.
Options: -d or --daemon: start in background, supress stdout,
log stderr into either /var/log/tvserver.log or ~/.mplayer/tvserver.log
-p or --port: use this port for incoming connections (default: 55555)
-n or --card
-c or --control: set volume to max,mute and select for capture the card
when new client arrives using amixer. Defaults to card 0, control Aux.
Here are some examples showing how to connect to the tvserver:
mplayer http://localhost:55555/
mplayer http://linuxbox.net:55555/SR5
tvchannels.cgi - This is a CGI script to advertise your TV server.
It lists the channels and provides a playlist called tv.pls
The clients must open them using: mplayer -playlist tv.pls
You have to copy or symlink this into a cgi-bin directory.
You have to set the tvserver port and the channel list file
by hand on the beginning of the script.
tvconf - A configuration file called ~/.mplayer/tvconfig holds a number
of configuration options. tvconf is a way to modify and check them.
Some options like the brightness can be modified only when
the TV player is running to prevent accidental modifying.
Some command line options (the others are described under TV Config Options):
list [regex] - list number,channel,channel name of the channels
matching regex (or all of them if no regex specified)
xosd - display using osd_cat a brief report in the following form:
Channel Name
channel,brightness,contrast,saturation
tvrecord - Records TV programs. It has two presets: hi and low quality.
(ex: tvconf q hi) Type --help or -h for a quick usage info.
Type the --silent (or -s or -q or --quiet) parameter
if you don't want to see what is being recorded (conserving CPU time).
Type one moment to specify when to stop recording. Ex: tvrecord 21:20
Type two moments to specify an interval. Ex: tvrecord 21:00 23:00
You can also specify the channel (ex: SE16) to record
otherwise the last watched channel will be recorded.
Any unrecognized parameter will be treated as a final command to execute
on the end of recording (but only if it reaches the timeout not if you
stop recording earlier). For example the command:
tvrecord -s 21:00 23:00 SE16 'init 0'
will wait until 9pm, record until the SE16 channel until 11pm then
it will shut down the computer if you have root privileges.
If the recorded file's size reaches 4GB tvrecord will start another file
with the same name but with a postfix, ex: Video-20060704-223538_2.avi
You probably want to reencode the recorded file(s) because
the hi preset is 640x480 6000kbit mpeg2 and
the lo preset is 512x384 3000kbit mpeg2.
For example use the following script to reencode your files
(maybe you want to lessen the vbitrate):
#!/bin/sh
file="Video-20060704-223538.avi"
encodepar="-force-avi-aspect 4:3 -vf hqdn3d=2:1:2 -ovc lavc -lavcopts vbitrate=1400:mbd=1:trell:v4mv"
mencoder "$file" $encodepar:turbo:vpass=1 -oac copy -o /dev/null
mencoder "$file" $encodepar:vpass=2 -oac copy -o "Reencoded-$file"
rm -f divx2pass.log
tvtimeshift - TV Time Shifting. Start it, press the pause button
and you can go to the bathroom without missing anything :-)
If you have a memory FS, you can use it to spare your hdd.
EX: tvconf memdir /tmp OR tvconf memdir /dev/shm
Unfortunately you cannot seek while timeshifting or recording.
Try using the speed_set command as a fast forward, but be aware that
the speed_set command may result in really high CPU usage which will
ultimately cause mencoder to drop video or even audio frames.
The script deletes immediately the already watched parts of the
tv program so it uses only as many disk space (or RAM) as you are timeshifted.
tvtsinfo - Displays approximately how much you are timeshifted.
The parameter -q or --quiet suppresses the error message when
tvtimeshift is not running.
tvvolume - MPlayer prefers to pass the sound directly from TV tuner to your
soundcard. Configure the card number and the mixer control using
tvconf (defaults: card=0 and control=Aux) and this script allows you
to control the volume of the sound. It also draws a lame looking slide.
If you don't see the slide, you probably don't have the specified font.
Open tvvolume and edit the osd_cat font value. Try xlsfonts.
I recommend the following lirc configuration:
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.
TV Config Options (to use with tvconf):
brightness, contrast, saturation: example of usage
begin
button = GREEN
prog = mplayer
config = run "tvconf brightness -20"\nosd_show_text "TV Brightness: -20"\ntv_set_brightness -20
config = run "tvconf brightness 0"\nosd_show_text "TV Brightness: 0"\ntv_set_brightness 0
end
dir: a place to save images, videos, thimeshift chunks.
memdir,control,card,q: explained above
pp: image postprocessing filter to use. The default is a pretty good combination.
chlist: filename containing the list of channels. Must contain lines like: SR7 National Geographic
vo: video output to use with TV. Currently accepts only sdl, xv or x11
xlayout: X server layout to use when starting new X servers (the same effect as setxlayout has on mcatcher)
lircconf: if you want to use a different lirc config file for the tv player here is the place to set it's filename
osdcolor,osdfont: color and font passed to osd_cat (to display channel,volume,timeshift info).
Try xlsfonts. Default values are lightgreen,-misc-fixed-medium-r-normal--32-0-100-100-c-0-iso8859-1
+,-,@: next channel,previous channel and recall channel.Example:begin
button = RECALL
prog = mplayer
config = tv_last_channel\nrun "tvconf @"
end
begin
button = CH_UP
prog = mplayer
config = tv_step_channel 1\nrun "tvconf +"
end
begin
button = CH_DOWN
prog = mplayer
config = tv_step_channel -1\nrun "tvconf -"
end
And finally you can use channel presets like this:
begin
button = 9
prog = mplayer
config = tv_set_channel 50\nrun "tvconf 50"
end
which will jump to the 50th item in the channel list file.
3)
Subtitle manipulation scripts:
sub2srt - a simple script that converts a .sub into an .srt
- usage
- sub2srt [framerate] file [[framerate] file ...] The default framerate is 23.976 srtshift - see srtshift --help for a list of parameters
- Examples
- srtshift 2 subtitles.srt - shift with 2 seconds
srtshift -2 21:00 subtitles.srt - shift with -2 seconds starting from 21 minutes
srtshift 23.976-25 subtitles.srt output.srt - change fps and put the result in output.srt
Sometimes the only problem with an SRT is that it was converted with the
wrong fps value. In this case either 23.976-25 or 25-23.976 will correct the file.
If not, try different combinations with framerates 23.976, 24, 25 and 29.97
Some subtitle files contain really long lines that can take up the whole screen.
In this case try breaking these long entries like this:
srtshift -b subtitles.srt
This feature is very experimental. The script can decide at which charater to break the long
entry but there is no way it could determine correctly where to break the time interval
so try using:
srtshift -b -m subtitles.srt
which will leave a strange looking mark at every broken subtitle.
Now you can adjust the timing by hand. When you are done a simple
srtshift subtitles.srt
will remove the marks.
srtadjust - sometimes to correct a subtitle file you would have to say for example:
srtshift 13.42 29.97-23.976 subtitles.srt These parameters are really hard to guess or calculate. In this case: cp subtitles.srt subtitles.csrt Then open subtitles.csrt with a text editor and on the beginning of the file put a line containing 4 time values for example: 00:00:55,522 00:02:46,410 01:36:59,580 01:47:30,400 The first 2 means where the first entry starts and where it should start the last 2 means where the last entry starts and where it should start. You can determine these values by watching the movie's beginning and end. There is no need to put exactly the first and last entries but the longest the distance between the entries the more precise the adjustment will be. In the end just type: srtadjust and the subtitles.srt file will contain the correct subtitle file. Of course this only works if the subtitle file was created for the movie version you have. If there are extra or missing subtitles in the file your work is not over yet.
4)
Statistical tools:
mcounter - a small script that measures a time interval until it receives
a HUP signal, then displays the measured time using osd_cat.
For an example of usage see the BOSS_KEY above.
msum - summarizes the second entries (playtime) from your mcatcher.log file.
you can give any number of regular expressions to filter the summarized entries. Example:
msum 'Stargate SG1' '!3x'
summarizes all watched Stargate episodes except season 3.
msum 'comedy|action'
summarizes all movies containing (in the filename) either `comedy' or `action'.
Dirnames in the regexes are normalized to their full path.
Use the --head or -h and --tail or -t options summarize only the first or last part of the
results. They can be repeated as many times as you want, ex: msum --head 100 -t 3 --head 1
If you give a negative number to the head or tail parameter it will be interpreted as the
number of total lines minus the parameter ex:
msum -h -1
will summarize every entry except the last one.
moviesize - creates a file called moviesizes.txt in the current directory. The file will contain a list
of movie files and/or directories containing movie files together with their properties
sorted by length. Just go to a directory containing movies/music or a directory containing
subdirectories with movies (movies broken into several files generaly are stored
in one directory), type moviesizes and you will understand.
This is the whole story in a nutshell. If you find any bugs (which you probably will) or have any ideas regarding to the package, do not hesitate to contact me.
mplayer-tools Copyright (C) 2006 Soos Gergely <soger@users.sourceforge.net> mplayer-tools comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please refer to the COPYING file for details.
