Google Answers Logo
View Question
 
Q: change mp3 bit-rate on the fly (php, linux) ( Answered,   0 Comments )
Question  
Subject: change mp3 bit-rate on the fly (php, linux)
Category: Computers > Programming
Asked by: isoundcom-ga
List Price: $60.00
Posted: 06 Apr 2005 12:33 PDT
Expires: 06 May 2005 12:33 PDT
Question ID: 505895
I have a large library of mp3s and need to figure out a way to stream
low quality versions to dial-up web users.
I figure there must be a way to change the bit-rate of the
high-bit-rate mp3 without actually changing the file or having to make
2 copies.

This needs to be a server side (linux) solution. NOT software for converting mp3s.

Again, this is a VERY large catalog of mp3s and having 2 files for
each song with different bit-rates is NOT an option.

I have seen other sites that do this with .m3u.
Thanks!

Request for Question Clarification by alienintelligence-ga on 06 Apr 2005 13:21 PDT
Hi isoundcom,

Since you are intending on 
streaming... are you familiar 
with the ShoutCast Linux server?
[ http://www.shoutcast.com/download/files.phtml ]

If I remember correctly,
my Win32 version of this
software allowed for sending
very "thin" streams, down
to mono 8bit and 11kHz.
The original mp3's aren't
affected.

I used to stream within
my house LAN to a 'pre-Pentium'
computer that couldn't handle
the mp3's larger formats.

Worked great and didn't have
any latency (on a LAN).
I don't see why you would
experience any issues with
running a thin stream on
the web, depending on your
web service's contention,
and how many clients you 
will serve to.

-AI

Clarification of Question by isoundcom-ga on 06 Apr 2005 13:50 PDT
From what i understand Shoutcast allows streaming of playlists.
I need to be able to stream the individual files when clicked upon.

I don't believe this would satisfy our needs.
Thanks.
Answer  
Subject: Re: change mp3 bit-rate on the fly (php, linux)
Answered By: leapinglizard-ga on 06 Apr 2005 15:04 PDT
 
Dear isoundcom,

The solution to your problem is a pair of free software packages published 
by the Shoutcast crew.

The first is the Shoutcast streaming server, downloadable as a precompiled
Linux binary. See the third entry on the following page.

Shoutcast: Downloading
http://www.shoutcast.com/download/files.phtml

The Shoutcast server itself doesn't do any mp3 decoding or transcoding,
since it expects a stream from a separate audio player or from one of
its input plugins. One such plugin is Shoutcast DSP (Digital Signal
Processing). The DSP plugin comes as part of a package variously called
the Shoutcast Broadcasting Tools or Shoutcast Trans. You can download
it using the first link below the header at the following address.

Shoutcast: Shoutcast Broadcasting Tools
http://www.shoutcast.com/download/broadcast.phtml#posixdownload

What you get with the package is a precompiled Linux binary called
sc_trans_linux, which will take care of launching the Shoutcast server and
feeding it an audio stream at the bitrate you specify. You'll also have to
make one or more playlists to specify the directories from which you wish
to stream files, and specify other settings in the configuration file.

Full details are given on the following page. The pathnames in this
tutorial may differ from those on your machine, but the principles are
the same. See section 3, "Setting up SHOUTcast Trans". The Bitrate setting
lets you specify the streaming rate of your mp3 files in bits per second.

Gentoo: Chris White: Streaming Radio With SHOUTcast
http://www.gentoo.org/doc/en/shoutcast-config.xml?style=printable

It has been a pleasure to address this question on your behalf. If you
find fault with my answer, please inform me through a Clarification
Request so that I may fully meet your needs before you assign a rating.

Regards,

leapinglizard

Request for Answer Clarification by isoundcom-ga on 06 Apr 2005 16:36 PDT
From what i understand Shoutcast allows streaming of playlists.
I need to be able to stream the individual files when clicked upon.

I don't believe this would satisfy our needs.

These files are being served from an internet site and the solution
needs to be changable and adaptable based on those needs.

Not just a bundled package like shoutcast.

Clarification of Answer by leapinglizard-ga on 06 Apr 2005 16:53 PDT
Shoutcast is still a good solution for you. Although it is often used
to stream a large playlist, it is not limited to these radio-like
applications. You shouldn't think that a playlist is some kind of
heavy-duty apparatus.

To stream a single file, you need merely provide a three-line text
file with a .pls extension. Thus, you can crawl your music directories
and make a .pls file for each file you wish to stream. As an
alternative, you can dynamically generate a .pls file for the
listener's selected file using a .cgi script.

leapinglizard

Clarification of Answer by leapinglizard-ga on 06 Apr 2005 16:59 PDT
The .m3u approach you mention, by the way, is exactly the same as that
of using .pls files. A .m3u is itself just a playlist, so you would
have to make one for each song in your collection.

It occurred to me that an alternative to using CGI is to exploit the
URL-rewriting capabilities of Apache. You can add rewriting rules to
your httpd.conf file so that whenever a user requests a .mp3 file from
your server, the request is forwarded to a custom program that
generates or points to a .pls file and launches Shoutcast Trans to
start streaming the .mp3 at the desired bitrate.

leapinglizard

Clarification of Answer by leapinglizard-ga on 06 Apr 2005 17:01 PDT
Here is a handy tutorial on using Apache rewriting rules.

A List Apart: URLs! URLs! URLs!
http://www.alistapart.com/articles/urls/

leapinglizard

Request for Answer Clarification by isoundcom-ga on 06 Apr 2005 19:44 PDT
Thanks for the clarifications.

I'm playing around with it right now.

My only problem now is that it seems that shoutcast limits the music
files that you can use to only a directory named "content" and doesn't
allow subdirectories under this dir.

Let me know if I'm missing something here or if there's a way around this.

The mp3s on our server are sorted in many diff. directories and just
one content dir. wouldn't work.

Thanks!

Clarification of Answer by leapinglizard-ga on 06 Apr 2005 20:07 PDT
From what I understand, the directory specifier is recursive.
Shoutcast should recognize .mp3 files located anywhere in the file
hierarchy below the content directory.

Another possibility is to make one flat directory containing softlinks
to all your .mp3 files. As a preliminary step, you would write a
script to crawl your music files and link them all from that directory
using "ln -s".

leapinglizard
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy