LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cat, fifos, and mp3 streams (https://www.linuxquestions.org/questions/linux-general-1/cat-fifos-and-mp3-streams-403640/)

ilikejam 01-15-2006 12:10 PM

cat, fifos, and mp3 streams
 
Hi all.

Here's the setup:
I'm attempting to create a low-tech streaming server, using only mplayer, ssh and a few standard Unix tools.

I have mplayer (running on host home1) dumping an mp3 stream from a shoutcast server into a fifo called stream.dump.
I can then use 'ssh user@home1 "cat stream.dump" > mpg123' to listen to the stream on a different machine (work1). This works just fine.
If I try to run 'ssh user@home1 "cat stream.dump" > mpg123' on another machine (work2), the stream to work1 gets interrupted (sometimes this causes mpg123 on work1 to stop, sometimes it just causes a blip in sound).

I would like to know why the stream is interrupted at all. I was under the impression that cat'ing twice from a file (in this case a fifo) should work fine.

Any ideas? Any suggestions for other ways to do this (only using mplayer, ssh and the usual Unix setup)?

Cheers.

Dave

Tinkster 01-15-2006 01:16 PM

Could depend on varied things, e.g. the CPU load on the
streaming machine. ssh (specially when used with compression)
can start off with a nasty CPU spike, particularly if the CPU
isn't very grunty ;}).


Cheers,
Tink

ilikejam 01-15-2006 02:06 PM

The machine is idle (as in load avg 0.01), and the same thing happens with 'CompressionLevel 9' and with 'Compression no'.

It's an Athlon 2500...

The sound blip also happens if I cat from the stream.dump fifo on the local (home1) machine, so it's definitely just the act of cat'ing which is causing the problem.

I got
Code:

Illegal Audio-MPEG-Header 0x4c353740 at offset 0xfffffffb.
Skipped 272 bytes in input.
Illegal Audio-MPEG-Header 0x91977aec at offset 0xfffffffb.
Skipped 272 bytes in input.
mpg123: Can't rewind stream by 37 bits!
Illegal Audio-MPEG-Header 0x657a355c at offset 0xfffffffb.
Skipped 272 bytes in input.
Illegal Audio-MPEG-Header 0x89844381 at offset 0xfffffffb.
Skipped 292 bytes in input.
Illegal Audio-MPEG-Header 0x520f3500 at offset 0xfffffffb.
Skipped 104 bytes in input.

from mpg123 last time I tried this.

Dave

JuddRogers 01-15-2006 06:11 PM

In summary:
You have one process dumping to a fifo, start another
process reading that fifo, all is good. You add a third process reading the same fifo and get mp3 errors.

I suspect the problem is the third process does not get to read the first few blocks from the fifo and so the MP3 data stream is a bit off.

To test, start the two readers first so they block waiting for data, then start the writer. If both are happy, then this is most likely your issue.

ilikejam 01-16-2006 11:49 AM

Hmmm.

It seems cat'ing the same FIFO to two audio players causes corruption for both streams (I'm doing this locally on my home machine now). I think that plan will have to go out the window.

Anyone got any ideas? Is it possible to have two instances of netcat (nc) listening to the same IP port for some loopback network streaming?

Dave


All times are GMT -5. The time now is 12:15 AM.