Announcement

Collapse
No announcement yet.

mplayerstart - resumable/tv-out wrapper script

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    mplayerstart - resumable/tv-out wrapper script

    Updated: Nov 10, 2009 - Updates to the mplayerstart script can now be found at
    http://igurublog.wordpress.com/downl...-mplayerstart/
    The versions and descriptions below are outdated.


    Here is an updated version of the mplayerstart script that adds some
    functionality to the previous one posted here. I'm sharing this here in case
    others want to use it, or use bits of the code in their own scripts.

    mplayerstart is a wrapper script for mplayer which allows the user to resume
    playback of a previously played file, supports a tv-out mode, disables the KDE
    screensaver, and a few other things. This version adds a check to see if KDE is
    running, kmix volume level restoration for each resumed file, support for
    resuming audio files, automatic playback of the last played file, and acceptance
    of .resume files on the command line.

    Just save this bash script, make it executable (chmod ugo+x mplayerstart), and
    use it to open media files. If you make an application shortcut to it or add it
    to the K menu, you can then associate it with avi and other media files in the
    file manager. Then you can just click on the movie or music file to have
    resumable playback (very slick).

    The only thing this script requires is a folder to store the resume files (a few
    bytes each) and to temporarily store mplayer console output (which can be a few
    dozen MB, and is deleted when playing the movie is finished). By default, the
    script uses the folder ~/.mplayerstart/ for this data.

    What mplayerstart does:

    * This version first checks to see if KDE (kdesktop) is running. If it isn't,
    it skips the KDE features automatically.

    * mplayerstart plays the media file specified, and when you quit mplayer, saves
    a .resume file which records where playback was stopped, as well as the kmix
    volume levels in use when playback was stopped. mplayerstart also disables the
    KDE screensaver while playing video files.

    * The next time mplayerstart opens a file with the same name as the above media
    file (regardless of location), it can resume playback, and also set the kmix
    volume levels to their last used level for this file.

    * mplayerstart can also automatically resume the last played file.

    * When using the --tv switch, mplayerstart will create an X :1 session and send
    mplayer's output there, which is useful for NVidia (and other?) video cards with
    TV-Out. Just set up your xorg.conf file as described here:
    http://en.wikibooks.org/wiki/NVidia/TV-OUT

    Usage:

    Code:
    mplayerstart --resume movie.avi
    plays the movie from the resume point (if any) and creates a new resume point.
    If you save the above command (mplayerstart --resume) as an application shortcut
    or add it to the K menu, you can then associate it with avi and other media
    files in the file manager for one-click resume.

    Code:
    mplayerstart movie.avi
    If you leave out the --resume switch as shown above, mplayerstart will begin
    playback at the beginning of the media file and will create a new resume point
    when finished.

    Code:
    mplayerstart --resumelast
    plays the last played media file from the resume point (if any) and creates a
    new resume point. If you save the above command as an application shortcut or
    add it to the K menu, you can then associate it with a keyboard shortcut (I use
    Windows-R) to quickly resume playback.

    Code:
    mplayerstart movie.resume
    passes a .resume file for playback. If you associate .resume files with the
    above command, this allows you to browse the folder of resumeable files (found
    in ~/.mplayerstart/ by default) and click on a .resume file. If mplayerstart
    can't find the media file in it's last known location, it will search up to two
    folders recursively (configure these folders in the script).

    Notes:

    * mplayerstart plays video files in full screen mode without a GUI. To quit
    playback press 'q'. For other keyboard shortcuts consult 'man mplayer'.

    * Audio files are played back in GUI mode. When the audio file is done playing,
    press 'q' or close mplayer. The .resume file will not be saved until you quit
    mplayer.

    * You can customize the location of mplayerstart's .resume files in the script
    at the top of the file (just load the script into a text editor).

    * After playback, mplayerstart will not re-enable the KDE screensaver if other
    mplayer's are still running.

    * This new version of mplayerstart will read the .resume files created by prior
    versions, but will save .resume files which are NOT compatible with the prior
    version. You may want to backup your resume folder before testing this version.

    Tips:

    * If you want to quit mplayer without saving the resume point, press Page-Up
    repeatedly until mplayer quits. (PageUp fast-forwards 10 minutes - thus the end
    of file will be reached and no resume point will be saved.)

    The script:

    Please use the updated script at
    http://igurublog.wordpress.com/downl...-mplayerstart/
    Check out my blog for useful scripts and tips... http://igurublog.wordpress.com

    #2
    Re: mplayerstart - my resumable/tv-out wrapper script

    I just edited the script above to correct one issue. If you're interested in the details...

    I noticed that if the movie was playing for awhile, when mplayer quit it took a long time for the script to finish. The result was that if you started the same movie before it finished, it appeared the resume was not working correctly. The problem was the tail command - for some reason it wasn't just outputing 10 lines. I added a --bytes=350 to the tail command and that appears to have corrected this issue.
    Check out my blog for useful scripts and tips... http://igurublog.wordpress.com

    Comment


      #3
      Re: mplayerstart - my resumable/tv-out wrapper script

      Nice trick to remember the video position, I did the same in my c++ app I wrote to manage my movies, got the idea from smplayer. Works rather well. What I did was substract 20 seconds from the stored position though, so it begins just a little more earlier, I thought that was somewhat more accurate.
      Greetings from Groningen Netherlands

      Comment


        #4
        Re: mplayerstart - my resumable/tv-out wrapper script

        Hi Jean, Yes it is a good trick and works surprisingly well. I wasn't sure if writing the console output would slow things down, but the drive doesn't even look that busy. I subtracted 5 seconds when doing the resume instead of your 20, which generally brings it back a couple seconds before the actual quit. This can be adjusted by changing the line "(( rx = restime - 5 ))". Also, it won't create a resume point less than 15 seconds into the video.
        Check out my blog for useful scripts and tips... http://igurublog.wordpress.com

        Comment


          #5
          Re: mplayerstart - my resumable/tv-out wrapper script

          Yes saving all that data is hardly noticable, surprised me too.

          I saved your bash code, I'm only beginner at bash but I think it's very powerfull for us tinkers.
          Greetings from Groningen Netherlands

          Comment


            #6
            Re: mplayerstart - my resumable/tv-out wrapper script

            I have modified the original post and script above with an improved version of mplayerstart. I've been using it successfully for awhile but please let me know of any issues you encounter.
            Check out my blog for useful scripts and tips... http://igurublog.wordpress.com

            Comment


              #7
              Re: mplayerstart - resumable/tv-out wrapper script

              Updated for KDE4 - tested on Kubuntu Intrepid beta.
              Check out my blog for useful scripts and tips... http://igurublog.wordpress.com

              Comment


                #8
                Re: mplayerstart - resumable/tv-out wrapper script

                Version 1.3.1 and future updates to this script are now posted to my blog at
                http://igurublog.wordpress.com/downl...-mplayerstart/
                Check out my blog for useful scripts and tips... http://igurublog.wordpress.com

                Comment


                  #9
                  Re: mplayerstart - resumable/tv-out wrapper script

                  Version 1.4.0 of mplayerstart is available. This update adds more flexibility for various TV display setups, including Xinerama, separate X displays, and once again the ability to xinit a display just for mplayer. This also adds an “auto” tvmode which uses the current display for playback. Also, mplayerstart now stops the X, KDE3, KDE4, and Gnome screensavers during playback. Plus, mplayerstart pops up dialogs using either Xdialog or kdialog, to give feedback on functions like rewind. The volume level restoration code has also been rewritten to use amixer, which should be more portable.
                  http://igurublog.wordpress.com/downl...-mplayerstart/
                  Check out my blog for useful scripts and tips... http://igurublog.wordpress.com

                  Comment

                  Working...
                  X