带管道的 MPlayer 无限循环

MPlayer infinity loop with pipe

我想使用 mplayer 无限循环播放视频,中间没有中断。所以我用 mkfifo 管道试了一下。喜欢这个 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

有人知道为什么这不起作用吗? 不知何故,管道只能装满一次。 还是因为视频格式.avi?但是我用 .mp4 试了一下还是不行。

可能更好的主意是使用 mplayer 的 slave 模式;这会让你控制它,同时让它自由地 cache/seek 并用真实的视频文件做任何它想做的事。

slave 模式是一个简单的文本协议,在标准输入上有查询和回复。在这里描述 http://www.mplayerhq.hu/DOCS/HTML/en/control.html and here http://www.mplayerhq.hu/DOCS/tech/slave.txt

但您可以在互联网上搜索更多信息和示例。

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

虽然可能需要更多考虑(例如,获取视频长度,不确定缓存选项等),但此方法可行(视频时长为 25 秒)

编辑:这似乎更好:

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

这只是永远循环一个文件。老实说,我不确定是否需要管道等。

edit2:我错过了您想要流畅播放的部分。在文件名之后放置循环可解决此问题:

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