[MPlayer-users] streaming mplayer

Ariel asmplayer at dsgml.com
Wed Sep 26 07:28:23 CEST 2007


On Tue, 25 Sep 2007, Jerry Geis wrote:

> I am starting mplayer with a command like:
> mplayer  http://camera/img/video.asf  -dumpstream -dumpfile
> /tmp/fifofile.mp4
>
> I then wrote a small program that reads from /tmp/fifofile.mp4 and sends
> it out over connecting sockets.
>
> The first mplayer  connection reads and shows the camera data.
> The second mplayer connection says "filling cache" and never displays
> anything.
>
> Is there something wrong about what  I am attempting?
> Can I not just "relay" the mp4 data that is read from the fifo?

You can only read from a fifo once. (If you try to read from it more than 
once each reader will get alternating lines.)

When the second connection occurs it sends data starting from the middle 
of the file (I'm assuming your code copies the fifo data, I didn't check).

I don't think mp4 files can be played from the middle. They probably need 
the header.

Try a different file format that can be 'restarted' as it's called, or 
resynchronized, i.e. played from the middle of the file. MPEG2 can do it, 
there might be a way of re-containering the mp4 to do that, without 
spending the cpu to reencode.

You might also try always sending the header to a connecting player, then 
sending video data from the middle. That might work, if the player is 
error-tolerant. I don't know how big the mp4 header is.

Test it:

Use dump stream on the connecting mplayers, see what they put in the 
stream. Try your program on an mpeg2, and try it on a real file rather 
that a fifo.

Also: if you don't read from a fifo the writer will block and wait for a 
reader, not being able to write will cause mplayer to disconnect from the 
stream it's reading. Make sure your program always reads from the fifo, 
even if no one is listening to it. Or have it start mplayer automatically 
on the first connection, and close mplayer when no one is listening.

 	-Ariel



More information about the MPlayer-users mailing list