0

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

From here I read that MPlayer can read from stdin (not named pipes).

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

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

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

but still no luck.

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

Community
  • 1
  • 1
Matteo Giani
  • 76
  • 2
  • 7

1 Answers1

0

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

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...

Community
  • 1
  • 1
Riccardo Petraglia
  • 1,943
  • 1
  • 13
  • 25
  • Hi @RiccardoPetraglia, and thanks - I'm afraid this would not yield the desired behavior, which is to play the data as I input them. But maybe this is just not what mplayer is meant to do :) – Matteo Giani Nov 17 '16 at 09:00