IgnorantGuru's Blog

Linux software, news, and tips

Script: mplayerstart

«Downloads

Download Links:
Script: downloadbrowseauthenticateinstructions
Debian/Ubuntu: packagesPPA
Arch Linux: AUR
Description: Wrapper script for mplayer which adds resumable playback; disables X, KDE, and Gnome screensavers; restores last volume levels; sends output to selected display
Recommended For: Linux
Tested On: Aptosid; Arch Linux; Kubuntu
Requires: mplayer zenity (optional: alsa-lib xdialog kdialog)
License: GNU GPL v3     * SEE DISCLAIMER *
Related: ripdvd
Feedback: commentsissues

UPDATE 2014-Jan-18: The mplayerstart script does not work correctly with mplayer2. (If you want to use it, in the script send mplayer’s output to the log file with &> rather than >)

Though it should still work with mplayer (v1), the mplayerstart script is no longer maintained. I strongly recommend giving the mpv video player a try. mpv is a fork of mplayer/mplayer2, and includes most of the resume features of mplayerstart. For example, mpv’s ––save-position-on-quit option (or quitting using Shift+Q) creates a resume file for the next time the video is played. It also restores mpv’s volume (though not the system volume) for each file. mpv includes many improvements.

See mpv homepage, mpv options & other mpv manpages.

If you use SpaceFM, check out my new SpaceTV plugin, which includes some of the functionality of mplayerstart. Its spacetv.sh script can also be used without SpaceFM for extended mpv resume abilities.

Contents

Overview


mplayerstart is a wrapper script for mplayer – it starts mplayer for you and adds some functionality, including the ability to resume video and audio playback from a saved position, send video output to another display, disable the screensaver during playback (X, KDE3, KDE4, and Gnome screensavers), and restore volume levels when resuming.

When integrated into your file manager and keyboard shortcuts, mplayerstart can be used to have resumable playback simply by clicking on a file or pressing a key. (If you play a video part way, quit, then click on the file again, it will resume playback where you left off.)

mplayerstart --help

Creates resume file for resumable playback; disables X, KDE, and Gnome
screensavers; restores last volume levels; starts mplayer in full-screen
mode; sends output to selected display.
Usage: mplayerstart [OPTIONS] ~/video/movie1.avi
       mplayerstart [OPTIONS] ~/.mplayerstart/movie1.avi.resume
       mplayerstart --resumelast
       mplayerstart --resumepre
       mplayerstart --rewind
       mplayerstart --tvmode MODE
Options:
--tv                sends output to TV Display
                      ignored when playing audio; overrides tvmode setting
--tvmode off        sets TV-out mode off for future videos
                      also cancels '--tvmode once'
--tvmode on         sets TV-out mode on for future videos
--tvmode auto       sets TV-out mode to auto-detect for future videos
                      video will play on current display
                      only works with separate X screens, not xinerama
--tvmode once       prepares to play only the next video on TV-out
                      overrides prior tvmode for next play only
--resume            resumes playing file from last stop point
--resumelast        resumes playing last played media file
--resumepre         resumes playing previous-to-last played media file
--rewind            deletes last played resume file
--mopt "OPTIONS"    passes additional playback OPTIONS to mplayer
Note: Resume files are auto-deleted after 60 days.
Current data folder for resume files: ~/.mplayerstart
Current TV option: -xineramascreen 2
Default Mplayer options: -vo xv -idx -fs -alang en


Examples:

# Play the movie from the resume point (if any) and create a new resume point
mplayerstart --resume movie.avi

# Play the movie from it's beginning (don't resume) and create a new resume point
mplayerstart movie.avi

# Resume playback of last played media file
mplayerstart --resumelast

# Resume playback of a movie specifying the resume file
mplayerstart ~/.mplayerstart/movie.resume

# Rewinds the last played file so next playback will be from the start
mplayerstart --rewind

# Resume playback and send output to TV
mplayerstart --resume --tv movie.avi

mplayerstart plays video files in full screen mode without a GUI. To quit playback press ‘q’. For other keyboard shortcuts see ‘man mplayer’.

Audio files are played back in GUI mode (gmplayer by default). When the audio file is done playing, press ‘q’ or close mplayer. The .resume file will not be saved until you quit mplayer.

Tip: If you want to quit mplayer without saving the resume point, press PageUp repeatedly until mplayer quits. (PageUp fast-forwards 10 minutes – thus the end of file will be reached and no resume point will be saved.) Alternatively, use the rewind command following playback (see the Keyboard Shortcuts section below).

TV-Out


By editing the User Options section at the top of the script, you can tell mplayerstart how to use your TV display. By default, it uses xinerama screen 2 for TV output, which is a typical setup with KDE4. You can change this to the X :1 display if you use a separate X display for your TV. Alternatively, mplayerstart can xinit a new X display just for mplayer, as described in the NVidia TV-OUT wikibook.

Volume Restoration


Along with the resume point, mplayerstart stores the volume levels for each file played, and will restore the volume level when resuming. For this functionality, amixer must be installed (installed with alsa-lib in Arch Linux). By default, mplayerstart restores the Master and PCM mixer controls. You can change this in the User Options section of the script.

File Manager Integration


The real power of mplayerstart is realized when it is integrated with your file manager. The following instructions are for KDE, but Gnome will be similar.

The first step is to create several menu items for mplayerstart commands. To do so, right-click on the K start button and select Menu Editor. Preferably in the Multimedia folder, right-click on the list of programs and select New Item. Give the new item the name “Mplayerstart Resume”.

In the command box for the “Mplayerstart Resume” item, enter:

mplayerstart --resume

Uncheck the “Enable launch feedback” box, and save the menu.

The next step is to associate .avi, .mpg, and other video file types with “Mplayerstart Resume”. In your file manager (Dolphin or similar), right-click on an AVI file and select Properties. Click the small wrench icon (Edit file type). Click Add. Select “Mplayerstart Resume” from the appropriate menu and click OK. Select “Mplayerstart Resume” in the Application Preference Order list, and use the Move Up button to move it to the top of the list. (This will make “Mplayerstart Resume” the default player for this media type.) Click OK, and OK again. Repeat this procedure for other video types, such as MPG, WMV, MKV, etc.

You can now simply click on a video file to have resumable playback. If you quit playback by pressing ‘q’, then play that file again, it will resume from where you left off.

Note that an alternative method in KDE for setting file associations is by using K|System Settings|Advanced|File Associations.

You can also associate the “Mplayerstart Resume” menu item with .resume files. This allows you to browse the list of resumable files (located in ~/.mplayerstart by default) and click on a .resume file to resume playback. You can do this with your file association editor or manually. Note: Due to the dot at the beginning of its name, ~/.mplayerstart is a hidden folder. You may not be able to see it listed in your home folder unless you have View|Show Hidden Files enabled in your file manager.

You can add additional menu items to enable more features in mplayerstart. For example, to create a menu item that sends output to the TV, create a menu item named “Mplayerstart TV” and use the command:

mplayerstart --resume --tv

Associate “Mplayerstart TV” with the same media file types (.avi, etc), but don’t make it the first item in the Application Preference Order list. That way when you want to play a video on the TV, you can right-click on the file and select Open With… “Mplayerstart TV”.

Keyboard Shortcuts


To create a keyboard shortcut which automatically resumes playback of the last video played, create a menu item named “Mplayerstart ResumeLast”. Use this command:

mplayerstart --resumelast

On the Advanced tab in the menu editor, set the Current Shortcut Key to Ctrl-Alt-R (or similar). Save the menu. There is no need to associate this menu item with a file type. Anytime you now press Ctrl-Alt-R, playback of the last resumable file will begin.

Other suggested keyboard shortcuts:

Menu Item Command Keyboard Shortcut Function
“Mplayerstart ResumeLast”
mplayerstart --resumelast
Ctrl-Alt-R resumes playback of the last video played
“Mplayerstart ResumePrevious”
mplayerstart --resumepre
Ctrl-Alt-P step backward through previous resumable files
“Mplayerstart Rewind”
mplayerstart --rewind
Ctrl-Alt-W start last played video at beginning next time it is played
“Mplayerstart TV Once”
mplayerstart --tvonce
Ctrl-Alt-T playback the next video on the TV
“Mplayerstart TV ON”
mplayerstart --tvmode on
Ctrl-Alt-Shift-T playback all videos on the TV
“Mplayerstart TV AUTO”
mplayerstart --tvmode auto
Ctrl-Alt-A playback videos on the current display
“Mplayerstart TV OFF”
mplayerstart --tvmode off
Ctrl-Alt-M playback all videos on the monitor

Installation Instructions


Follow the standard Script Installation Instructions. Alternatively, for Debian and Ubuntu a deb package and a PPA repository are available. On Arch Linux, mplayerstart can be installed automatically using the AUR.

Before running mplayerstart, install required packages using your package manager. For example, on Debian/Ubuntu:

apt-get install mplayer zenity

For volume level restoration, alsa-utils (amixer) is required.

For pop-up messages (eg File Not Found), zenity is used by default. xdialog or kdialog may also be used (set your preference in the User Defaults section at the top of the script). (kdialog is installed by default with KDE4. xdialog can be installed from extra in Arch Linux.)

By default, mplayerstart saves its .resume files and temporary files in ~/.mplayerstart/. You can change this by editing the User Options section. During playback, mplayerstart needs about 100MB of temporary free space in whatever folder you choose.

In addition, the User Defaults section of the script allows you to configure your default mplayer video options, TV display settings, and other features.

3 Comments »

  1. Hi IgnorantGuru,
    your script is great for a minimalist HTPC (base on filemanager).

    Do you plan other features ?
    I miss one, a per user rc config in ~/.mplayerstart folder.
    Because when you install via package manager it’s system wide (Mplayer, TV options …).
    Thx !

    Comment by mentat | October 31, 2012 | Reply

    • Thanks for the suggestion. I’m honestly not sure what will happen with mplayerstart – haven’t worked on it in awhile but use it all the time.

      Comment by IgnorantGuru | October 31, 2012 | Reply

  2. Hi. Just want to submit, what Ubuntu + nVidia proprietary driver give us the separate X screen under :0.1 number(not :1) , or :n.1, where n is main screen, so i’m using following User Options to run properly with –tv option:

    tvoption="-display `echo $DISPLAY | sed 's|\.0|\.1|'`"
    xinitdisplay="`echo $DISPLAY | sed 's|\.0|\.1|'`"

    Comment by Flashwalker | August 29, 2013 | Reply


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

Follow

Get every new post delivered to your Inbox.

Join 92 other followers