Search code examples
bashpipefifomplayermkfifo

MPlayer infinity loop with pipe


I'd like to use mplayer to play a video in an infinity loop with no interrupts between. So I tryied it with a mkfifo pipe. Like this one here.

mkfifo pipe
(cat pipe | mplayer -cache 10000 -cache-min 0 -really-quiet - ) &
cat video.avi >> pipe       
until [ -e /tmp/stop_loop ]   #stop file
do 
  sleep 20                    #video.avi is 25sec long
  cat video.avi >> pipe     #fill pipe with the video again slightly before the first video ends
done

Anyone an idea why this don't work? Somehow the pipe can be filled only one time. Or is it because of the video format .avi? But I tried it with .mp4 whith still no luck too.


Solution

  • while true
    do
    (cat pipe | mplayer -cache 10000 -cache-min 0 -really-quiet - ) &
    cat video.avi >> pipe
    sleep 25
    done
    

    This works (where the video is 25 seconds long) though probably needs more thought (e.g. get video length, not sure about the cache options etc.)

    edit: this seems better:

    mplayer -fs -loop 0 video.avi -really-quiet
    

    which is just loop a file forever. I'm not sure of the need to pipe etc. to be honest.

    edit2: I missed the part where you wanted a smooth stream. Putting the loop AFTER the filename fixes this:

    mplayer -fs video.avi -loop 0 -really-quiet