Re: Can Netjuke create MP3s on the fly?
Paul Westbrook <[email protected]> Tue, 3 Jun 2003 23:21:09 -0700
| Newsgroups | gmane.comp.audio.netjuke.user |
|---|---|
| Message-ID | <[email protected]> |
Hello,
The performance impact is not too bad for my situation. I can only
transcode one stream at at time, as lame takes about 80% of the cpu,
but that is because I am running netjuke on a pretty slow computer
(Power Mac G3 266 Mhz, running linux). When I am transcoding, I don't
see slow down on the web or mail servers that are also running on this
machine.
I also am about to upgrade to a faster x86 machine, I am sure that I
would be able to transcode multiple streams with this computer.
Some optimizations could be made to this script. It could be change
to not try to resample mp3 files that have a bit rate less than or
equal to the bit rate that lame would use for the streamed files.
--Paul
On Tuesday, June 3, 2003, at 01:57 PM, Chris Connors wrote:
> Note that Paul's script relies on LAME to do the bitrate
> normalization, so obviously, you have to have LAME installed.
>
> There was some discussion about the performance impact of re-encoding
> every outbound track, but I don't know if anyone discussed their
> experiences. Paul, is this a big resource hit?
>
> Thanks,
>
> Chris
>
> On Tuesday, June 3, 2003, at 11:03 AM, Paul Westbrook wrote:
>
>> Hello,
>> I think that I found a solution to this problem. Here is my
>> latest version of playmp3.php:
>>
>>
>> <?
>>
>> $filename = $_REQUEST['mp3file'];
>> $tr_name = (isset ($_REQUEST['tr'])) ? rawurldecode($_REQUEST['tr'])
>> : 'Netjuke playlist';
>> $ar_name = (isset ($_REQUEST['ar'])) ? rawurldecode($_REQUEST['ar'])
>> : '';
>> $al_name = (isset ($_REQUEST['al'])) ? rawurldecode($_REQUEST['al'])
>> : '';
>>
>> $bitrate = 64; // desired streaming bitrate
>> header("Content-type: audio/mp3");
>> set_time_limit(1800); // maximum length of a song
>>
>> $tr_name = addcslashes($tr_name, ' ');
>> $ar_name = addcslashes($ar_name, ' ');
>> $al_name = addcslashes($al_name, ' ');
>>
>> $filename = addcslashes($filename, ' ');
>>
>> $tr_name = addcslashes($tr_name, '&');
>> $ar_name = addcslashes($ar_name, '&');
>> $al_name = addcslashes($al_name, '&');
>>
>> $filename = addcslashes($filename, '&');
>>
>>
>> $tr_name = addcslashes($tr_name, ')');
>> $ar_name = addcslashes($ar_name, ')');
>> $al_name = addcslashes($al_name, ')');
>>
>> $filename = addcslashes($filename, ')');
>>
>> $tr_name = addcslashes($tr_name, '(');
>> $ar_name = addcslashes($ar_name, '(');
>> $al_name = addcslashes($al_name, '(');
>>
>> $filename = addcslashes($filename, '(');
>>
>> $tr_name = addcslashes($tr_name, '/');
>> $ar_name = addcslashes($ar_name, '/');
>> $al_name = addcslashes($al_name, '/');
>>
>> $tr_name = addcslashes($tr_name, '-');
>> $ar_name = addcslashes($ar_name, '-');
>> $al_name = addcslashes($al_name, '-');
>>
>> $filename = addcslashes($filename, '-');
>>
>>
>>
>> echo passthru("/usr/local/bin/lame --add-id3v2 --ta $ar_name --tl
>> $al_name --tt $tr_name -b $bitrate -f --silent
>> /data/www/html/netjuke/$filename - ");
>> ?>
>>
>>
>>
>> --Paul
>>
>>
>>
>>
>> On Wednesday, April 2, 2003, at 11:45 PM, Paul Westbrook wrote:
>>
>>> Hello,
>>> After doing some more testing, I have discovered that this does
>>> not work if there is a quote "'" character in the path of the file
>>> or in the id3 tags of the mp3. I haven't had any luck in figuring
>>> out how to escape the strings.
>>>
>>> If you have any ideas, I would appreciate it.
>>>
>>>
>>> Thank you,
>>>
>>> Paul
>>>
>>>
>>>
>>> On Thursday, March 27, 2003, at 11:56 AM, Paul Westbrook wrote:
>>>
>>>> Hello,
>>>> Thank you for your changes. It wasn't working for me in a lot
>>>> of songs
>>>> since I have spaces in many of my artists and albums. I needed to
>>>> urlencode the track information. Here are my changes:
>>>>
>>>> diff play.php play.php.orig
>>>> 83d82
>>>> <
>>>> 89,99c88,89
>>>> <
>>>> < # this is disabled - we go for resampling
>>>> < # if (!strstr($tr_location,"://")) $tr_location =
>>>> WEB_PATH."/".$tr_location;
>>>> <
>>>> < # new code
>>>> < if (strncmp('10.',$_SERVER['REMOTE_ADDR'],3) &&
>>>> strncmp('192.168.',$_SERVER['REMOTE_ADDR'],8) &&
>>>> strstr($tr_location,".mp3")) {
>>>> < if (!strstr($tr_location,"://")) $tr_location =
>>>> WEB_PATH."/
>>>> playmp3.php?mp3file=".$tr_location.'&tr='.specialUrlEncode($tr_name)
>>>> .'&ar='.specialUrlEncode($ar_name).'&al='.specialUrlEncode($al_name)
>>>> ;
>>>> < }
>>>> < else {
>>>> < if (!strstr($tr_location,"://")) $tr_location =
>>>> WEB_PATH."/".$tr_location;
>>>> < }
>>>> ---
>>>>> if (!strstr($tr_location,"://")) $tr_location =
>>>> WEB_PATH."/".$tr_location;
>>>>>
>>>>
>>>>
>>>> Here is my playmp3.php file:
>>>>
>>>> <?
>>>>
>>>> $filename = $_REQUEST['mp3file'];
>>>> $tr_name = (isset ($_REQUEST['tr'])) ?
>>>> rawurldecode($_REQUEST['tr']) :
>>>> 'Netjuke playlist';
>>>> $ar_name = (isset ($_REQUEST['ar'])) ?
>>>> rawurldecode($_REQUEST['ar']) : '';
>>>> $al_name = (isset ($_REQUEST['al'])) ?
>>>> rawurldecode($_REQUEST['al']) : '';
>>>>
>>>> $bitrate = 64; // desired streaming bitrate
>>>> header("Content-type: audio/mp3");
>>>> set_time_limit(1800); // maximum length of a song
>>>>
>>>> echo passthru("/usr/local/bin/lame --add-id3v2 --ta \"$ar_name\"
>>>> --tl
>>>> \"$al_name\" --tt \"$tr_name\" -b $bitrate -f --silent
>>>> \"/data/www/html/
>>>> netjuke/$filename\" - ");
>>>>
>>>> ?>
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> Paul
>>>>
>>>>
>>>>
>>>> Chuck Rider -Lists said:
>>>>> Here is another twist on the same theme.
>>>>>
>>>>> This one has two effects. First, it downsamples for any request
>>>>> from the
>>>>> internet and sends the files directly to the internal network.
>>>>> That way
>>>>> I can log on with the same name from work or home and have the
>>>>> system
>>>>> figure it out for me.
>>>>>
>>>>> Second, It passes the track, artist, and album names to lame for
>>>>> inclussion in the downsampled mp3. It also forces lame to generate
>>>>> both
>>>>> ID3v1 and ID3v2 tags. This way Windows Media Player (and other I
>>>>> suspect) display the info as the song plays.
>>>>>
>>>>> diff netjuke/play.php netjuke/play.php.orig :
>>>>> 88,96c88,89
>>>>> < # this is disabled - we go for resampling
>>>>> < # if (!strstr($tr_location,"://")) $tr_location =
>>>>> WEB_PATH."/".$tr_location;
>>>>> < # new code
>>>>> < if (strncmp('10.',$_SERVER['REMOTE_ADDR'],3) &&
>>>>> strncmp('192.168.',$_SERVER['REMOTE_ADDR'],8) &&
>>>>> strstr($tr_location,".mp3")) {
>>>>> < if (!strstr($tr_location,"://")) $tr_location =
>>>>> WEB_PATH."/
>>>>> playmp3.php?mp3file=".$tr_location.'&tr='.$tr_name.'&ar='.$ar_name.
>>>>> '&al='.$al_name;
>>>>> < } else {
>>>>> < if (!strstr($tr_location,"://")) $tr_location =
>>>>> WEB_PATH."/".$tr_location;
>>>>> < }
>>>>> ---
>>>>>> if (!strstr($tr_location,"://")) $tr_location =
>>>>> WEB_PATH."/".$tr_location;
>>>>>>
>>>>>
>>>>> and playmp3.php looks like:
>>>>> <?
>>>>>
>>>>> $filename = $_REQUEST['mp3file'];
>>>>> $tr_name = (isset ($_REQUEST['tr'])) ? $_REQUEST['tr'] : 'Netjuke
>>>>> playlist'; $ar_name = (isset ($_REQUEST['ar'])) ? $_REQUEST['ar']
>>>>> : '';
>>>>> $al_name = (isset ($_REQUEST['al'])) ? $_REQUEST['al'] : '';
>>>>>
>>>>> $bitrate = 8; // desired streaming bitrate
>>>>> header("Content-type: audio/mp3");
>>>>> set_time_limit(1800); // maximum length of a song
>>>>>
>>>>> echo passthru("/usr/local/bin/lame --add-id3v2 --ta \"$ar_name\"
>>>>> --tl
>>>>> \"$al_name\" --tt \"$tr_name\" -b $bitrate -f --silent
>>>>> \"/www/netjuke/$filename\" - ");
>>>>>
>>>>> ?>
>>>>> ------------------------------------------------------
>>>>>
>>>>>
>>>>>> Will Meyer <[email protected]> schrieb am 21.03.03
>>>>>> 14:45:45:
>>>>>>>
>>>>>>> My music collection is all FLAC, which I listen to directly at
>>>>>>> home.
>>>>>>> If I set up Netjuke, is there a way to configure it to generate
>>>>>>> MP3s
>>>>>>> from FLAC dyamically, maybe pre-caching whole albums or
>>>>>>> something but
>>>>>>> in > essence a way to keep a lossless format for most purposes
>>>>>>> and
>>>>>>> just get it to stream out MP3s for listening over lower-bandwith
>>>>>>> WAN
>>>>>>> connections? Is the code set up to be able to write a plugin for
>>>>>>> such without too > much trouble?
>>>>>>
>>>>>> Hi Will,
>>>>>>
>>>>>> I have used a former hint from the mailing list to set up netjuke
>>>>>> to
>>>>>> transcode mp3's on the fly to a lower bitrate for a single user.
>>>>>> In
>>>>>> this setup you can easily replace the 'transcode' thing with an
>>>>>> 'encode' thing. Well, as long as your machine is powerful enough.
>>>>>> And if you like to have it be done unconditionally, you can just
>>>>>> leave
>>>>>> out the bit with the user; and you would have to replace the *.mp3
>>>>>> with *.flc or whatever the suffix for FLAC's is.
>>>>>>
>>>>>> It goes like this:
>>>>>>
>>>>>> diff netjuke/play.php netjuke/play.php.orig :
>>>>>>
>>>>>> 88,101c88,91
>>>>>> <
>>>>>> < # this is disabled - we go for resampling
>>>>>> < # if (!strstr($tr_location,"://")) $tr_location =
>>>>>> WEB_PATH."/".$tr_location; <
>>>>>> < # new code
>>>>>> < if (($NETJUKE_SESSION_VARS["email"] == "[email protected]") &&
>>>>>> (strstr($tr_location,".mp3"))) { < if
>>>>>> (!strstr($tr_location,"://")) $tr_location =
>>>>>> WEB_PATH."/playmp3.php?mp3file=".$tr_location; <
>>>>>> $tr_location = separatorCleanup($tr_location);
>>>>>> < }
>>>>>> < else {
>>>>>> < if (!strstr($tr_location,"://")) $tr_location =
>>>>>> WEB_PATH."/".$tr_location; < $tr_location =
>>>>>> separatorCleanup($tr_location);
>>>>>> < }
>>>>>> <
>>>>>> ---
>>>>>>> if (!strstr($tr_location,"://")) $tr_location =
>>>>>>> WEB_PATH."/".$tr_location;
>>>>>>>
>>>>>>> $tr_location = separatorCleanup($tr_location);
>>>>>>
>>>>>> Basically this just calls playmp3.php with the approriate
>>>>>> parameter if
>>>>>> the user name is as specified and the file is an MP3.
>>>>>>
>>>>>> Additionally you need netjuke/playmp3.php which goes like this:
>>>>>>
>>>>>> <?
>>>>>>
>>>>>> $filename = $_REQUEST['mp3file'];
>>>>>>
>>>>>> $bitrate = 64; // desired streaming bitrate
>>>>>> header("Content-type: audio/mp3");
>>>>>> set_time_limit(1800); // maximum length of a song
>>>>>>
>>>>>> echo passthru("/usr/bin/lame -b $bitrate -f --silent
>>>>>> \"/srv/www/netjuke/$filename\" - ");
>>>>>>
>>>>>> ?>
>>>>>>
>>>>>> Here you can see the transcoding command. Just replace it with
>>>>>> anything appropriate. (Maybe you' ll have to de-flac and then
>>>>>> encode
>>>>>> to mp3 in a pipe.)
>>>>>>
>>>>>> Have fun
>>>>>> Matthias
>>>>>>
>>>>>> ps Just drop me an e-mail if you've got some question on the
>>>>>> above.
>>>>>>
>>>>>> __________________________________________________________________
>>>>>> ____________
>>>>>> Sie haben mehr zu sagen als in eine SMS passt? Mit WEB.DE
>>>>>> FreeMail ist
>>>>>> das jetzt kein Problem mehr!
>>>>>> http://freemail.web.de/features/?mc=021182
>>>>>>
>>>>>>
>>>>>>
>>>>>> -------------------------------------------------------
>>>>>> This sf.net email is sponsored by:ThinkGeek
>>>>>> Welcome to geek heaven.
>>>>>> http://thinkgeek.com/sf
>>>>>> _______________________________________________
>>>>>> Netjuke-users mailing list
>>>>>> [email protected]
>>>>>> https://lists.sourceforge.net/lists/listinfo/netjuke-users
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -------------------------------------------------------
>>>>> This SF.net email is sponsored by:
>>>>> The Definitive IT and Networking Event. Be There!
>>>>> NetWorld+Interop Las Vegas 2003 -- Register today!
>>>>> http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
>>>>> _______________________________________________
>>>>> Netjuke-users mailing list
>>>>> [email protected]
>>>>> https://lists.sourceforge.net/lists/listinfo/netjuke-users
>>>>
>>>>
>>>> --
>>>> Paul Westbrook
>>>> [email protected]
>>>> http://www.westbrooks.org
>>>>
>>>>
>>>>
>>>>
>>>> -------------------------------------------------------
>>>> This SF.net email is sponsored by:
>>>> The Definitive IT and Networking Event. Be There!
>>>> NetWorld+Interop Las Vegas 2003 -- Register today!
>>>> http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
>>>> _______________________________________________
>>>> Netjuke-users mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/netjuke-users
>>>>
>>> --
>>> Paul Westbrook
>>> [email protected]
>>> <http://www.westbrooks.org>
>>>
>>
>>
>>
>> -------------------------------------------------------
>> This SF.net email is sponsored by: eBay
>> Get office equipment for less on eBay!
>> http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
>> _______________________________________________
>> Netjuke-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/netjuke-users
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: eBay
> Get office equipment for less on eBay!
> http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
> _______________________________________________
> Netjuke-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/netjuke-users
-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.