Programming and Scripting :: Little help needed



I got an idea of web radio with only few components...
I plan to use poc to stream my mp3's to web. I can tke stream from standard input. But afaik it cannot take raw stream. If it could it would be easy to just generate playlist and play it with mpg123 using -s switch.
So I managed to get it working with this: cat `cat playlist.m3u`. This will simply ouput everything inside those files specified in 'playlist.m3u'.
Ok it's missing continous play and ramdomization etc...
But the main problem is that if there's a space(s) in the paths of mp3-files then cat cuts the line there and assumes that was the path of the file and then tires to find a file which is a rest of the path after the space.
Example: /home/dsl/My Music/song.mp3
cat sees that as two files: ''/home/dsl/My' AND 'Music/song.mp3'.

I've been trying to use sed to work around this problem,  but I haven't got any solution for this problem.
Any help?

Hmm. I might found a solution to this, but It's abit "CPU" consuming...
Code Sample
mpg123 -Z --list list.m3u -s | lame -r <additoinal switches> - - | poc <switches>


So after decoding mp3's with mpg123 then encode back to mp3 format suitable for streaming and output them directly to poc.

I could say this operation as "tweaking it to work". :p

EDIT: Well I could get only rumble out of it... (at few points I still could hear music.)
I tested it by outputting lame's data to a file and then listen it with xmms.

EDIT2: Okay. Now it works fine. I used wav stream instead of raw between mpg123 and lame.
Here's what I did:
Code Sample
mpg123 --list mylist.m3u -Zq -w - | lame -b 32 -q 9 - lowq.mp3


But I'd like to know a way to stream files in my playlist without any encoding/decoding...

Ok, if we can back up before you started encoding the files, you said they would stream fine but you had trouble with the format of the playlist. Is this correct?

So my gess is all you need to do is find out how to create a properly formatted playlist.
I have some questions:
What should a poc playlist look like? This is probably the most important issue.
Why are you using that redundant cat command?
Do you already have playlists made that you're trying to convert?
Is creating a playlist from scratch an option?

Quote
What should a poc playlist look like? This is probably the most important issue.
Poc can stream files specified in commandline or it can take data from standard input and stream it. I'd like to use stdin.

Quote
Why are you using that redundant cat command?
I assume you mean that cat `cat playlist.m3u`?
M3u playlist simply contain a path in each line (some might have commented lines). These paths are paths to music files.
See it for yourself:
Code Sample
wget -O - http://palm.zapto.org:8888/vast/recurse.m3u | less

Now if you cat file like this it will display just path's to music files on your screen. But if you grab the output of cat and paste it into another cat's as commandline arguments then prints the contents of these files specified in that list.
For example: If you have a text file (named index.txt) containing text:
Code Sample
/home/dsl/music/part1.txt
/home/dsl/music/part2.txt

Then you execute:
Code Sample
cat `cat index.txt` >> part1_and_part2.txt
Then you have created a file that will have the contents of both /home/dsl/music/part1.txt and /home/dsl/music/part2.txt in that order. By doing this to mp3-files but then instead of creating a huge combined mp3-file you might like to pipe the data to, for example to mpg123. I did that it worked quite well.

Quote
Do you already have playlists made that you're trying to convert?
Yes. M3u format.
Quote
Is creating a playlist from scratch an option?

Well m3u playlist format if the most simple way since only return character is used as mark that seperates the paths.

Now. Only problem with cat and this playlist is if the path contains spaces.
I need to make it understand that space is not end of file's path, only return character can determine it.

I think I misunderstood what you were doing.

Do you need both mp321 and poc to do this? I was thinking poc was a player, but i guess I was wrong?

I'm not seeing where encoding/decoding is related to filenames with spaces. Are you having two separate problems here? It sounds like you jumped from one issue to the other and back again without fully addressing either issue?

Next Page...
original here.