user937065
user937065

Reputation: 61

Linux tee command with multiple fifo. fifo blocks tee

I am trying to develope one program to play and record some rtmp streames. The program is developed in Qt.

i am using the rtmpdump and mplayer. since both are running in seperate process, i am using a fifo to pass the stream from rtmpdump to mplayer. I need seperate process because mplayer need to be controlled by user. so mplayer is runnig in slave mode.

this is working fine for playing the stream.

now i want to record the stream to another file. i know that i can use the mplayer to do that. but using a single mplayer it is not possible as it supports only either playing or recording. so thought of using the tee command to split the stream and use 2 mplayer process, one for recording and one for playing.

now the stream flows like this

rtmpdump | tee fifo_for_playing fifo_for recording 

one mplayer is reading the fifo_for_playing and another is reading fifo_for_recording.

now the problem is, since mplayer which supposed to record will start only when the user press record button, fifo_for_recording will block the tee as it is not opened. so playing also will not start.

can anybody suggest a solution or better way to achieve this? what i am trying to do is tee with non blocking fifo. so even if one fifo is not opened for reading, it will not block the tee..

Upvotes: 6

Views: 1978

Answers (1)

Emery Lapinski
Emery Lapinski

Reputation: 19

Fifos do not have a buffer (or if they have one it is very small). If you write to it and no one is reading you block, as you're finding out.

You could write a little program to read the fifo and buffer it in memory or to disk. Maybe the dd program can do that?

Or you could call with rtmpdump with the -stop option in a loop, and have it write its output to a file. Then process the files the old fashioned way without the fifo.

Upvotes: 1

Related Questions