YANNlK
YANNlK

Reputation: 13

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.

Upvotes: 1

Views: 518

Answers (2)

bob dylan
bob dylan

Reputation: 1498

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

Upvotes: 2

Probably a better idea would be to use mplayer's slave mode; this would let you control it while leaving it free to cache/seek and do whatever it wants with a real video file.

slave mode is a simple text protocol, with queries and replies on standard input. It is described here http://www.mplayerhq.hu/DOCS/HTML/en/control.html and here http://www.mplayerhq.hu/DOCS/tech/slave.txt

but you can search the internet for more info and examples.

Upvotes: 1

Related Questions