Mplayer和管道流 [英] Mplayer and pipe streaming

查看:60
本文介绍了Mplayer和管道流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用mplayer通过命名管道播放文件流.

I'd like to use mplayer to play a stream of files via a named pipe.

此处中,我读到 MPlayer可以读取来自stdin(未命名管道).

命名管道仍然可以通过以下方式在bash脚本中使用:

named pipes can still be used in a bash script this way:

mkfifo pipe
cat pipe | mplayer -cache 1024 -cache-min 10 -really-quiet - &
cat test.wav > pipe

问题是,在mplayer收到EOF之后,它退出并且我不能传递多个文件,而我希望mplayer继续通过管道播放文件.该问题在某种程度上类似于,从中启发了以下脚本(该脚本旨在保持管道打开):

the problem with this is that after mplayer receives an EOF, it exits and I cannot pass more than one file, while I'd like mplayer to keep playing files through the pipe. The problem is somehow similar to this, from which the following script, meant to keep the pipe opened, is inspired:

mkfifo pipe
cat pipe | mplayer -cache 1024 -cache-min 10 -really-quiet - &
exec 3>pipe
cat test1.wav >&3
cat test2.wav >&3
..
exec 3>&- # close the pipe

管道确实保持打开状态;但是,尽管mplayer的缓存已满,但除非关闭管道,否则我无法回放,在这种情况下,它仅播放第一个文件.我试图在文件后发送EOF信号:

the pipe remains indeed open; however, now despite the cache of mplayer getting filled, I get no playback unless I close the pipe, in which case it plays the first file only. I tried to send, after a file, an EOF signal:

mkfifo pipe
cat pipe | mplayer -cache 1024 -cache-min 10 -really-quiet - &
exec 3>pipe
cat test1.wav >&3
echo >&3
..
exec 3>&- # close the pipe

但仍然没有运气.

关于如何将mplayer用作命名管道中的流播放器的任何建议?

Any suggestions on how to use mplayer as a stream player from a named pipe?

推荐答案

您是否选中了

Did you check this one? In your case you should encapsulate all the cat commands:

mkfifo pipe
cat pipe | mplayer -cache 1024 -cache-min 10 -really-quiet - &
exec 3>pipe
(cat test1.wav test2.wav ) >&3
3>&- # close the pipe

这样,当命令遇到右括号时,还会发送EOF ...

In this way, when the command meets the closing parenthesis also send an EOF...

老实说,我不确定这是否是答案,但是评论太久了...:)

Honestly, I am not sure this is the answer, but it was too long for a comment... :)

如果这行得通,主要的缺点是内存使用量...

In case this will work, the main downside is the memory usage...

这篇关于Mplayer和管道流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆