scooter41 Posted October 29, 2007 Share Posted October 29, 2007 Hi There! I have a client who is wishing to sell mp3 downloads on his website, currently selling 128k, but now wanting to do 384 as well for an additional cost. I was trying to think of a good way to upload both, and thought perhaps use the same name but add 384 on the end of one of the file names and search for that on upload. Then I thought, maybe there is some kind mp3 compression software that can be done dynamically using a php script? then they could only upload 1 file to sort out both formats ? is this possible? Thanks for any help in advance. Scott Quote Link to comment https://forums.phpfreaks.com/topic/75225-solved-dynamic-mp3-compression-serverside/ Share on other sites More sharing options...
cooldude832 Posted October 29, 2007 Share Posted October 29, 2007 not in php enviroment, you might have a c program to do this that could run from exec(), but I would think the added resource useage would far outweight the burden of storing 1 additional file type. Quote Link to comment https://forums.phpfreaks.com/topic/75225-solved-dynamic-mp3-compression-serverside/#findComment-380454 Share on other sites More sharing options...
zq29 Posted October 29, 2007 Share Posted October 29, 2007 You could install LAME on the server, and re-encode with that... <?php $source = "path/to/320k/file.mp3"; $target = "path/to/128k/file.mp3"; `lame -b 128 $source $target` //I think that's how you set the bitrate with LAME ?> Quote Link to comment https://forums.phpfreaks.com/topic/75225-solved-dynamic-mp3-compression-serverside/#findComment-380455 Share on other sites More sharing options...
scooter41 Posted October 29, 2007 Author Share Posted October 29, 2007 perfect! I will try the LAME encoder and see how I get on with that thanks for the support Quote Link to comment https://forums.phpfreaks.com/topic/75225-solved-dynamic-mp3-compression-serverside/#findComment-380467 Share on other sites More sharing options...
scooter41 Posted October 29, 2007 Author Share Posted October 29, 2007 installed lame, and via SSH the following command works great, however in php no output file is created and no error is given either? lame -b 128 /var/...path name... /httpdocs/test.mp3 /var/...path name... /httpdocs/test2.mp3 <?php $source = "/var/...path name... /httpdocs/test.mp3"; $target = "/var/...path name... /httpdocs/test2.mp3"; $encode_cmd = "l"; echo exec( $encode_cmd ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75225-solved-dynamic-mp3-compression-serverside/#findComment-380497 Share on other sites More sharing options...
zq29 Posted October 29, 2007 Share Posted October 29, 2007 $encode_cmd = "l"; Your command isn't in there... Quote Link to comment https://forums.phpfreaks.com/topic/75225-solved-dynamic-mp3-compression-serverside/#findComment-380499 Share on other sites More sharing options...
scooter41 Posted October 29, 2007 Author Share Posted October 29, 2007 must have been a copy/paste error, this is how it is: <?php $source = "/var/...path name... /httpdocs/test.mp3"; $target = "/var/...path name... /httpdocs/test2.mp3"; $encode_cmd = "lame -b 128 $source $target "; exec( $encode_cmd ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75225-solved-dynamic-mp3-compression-serverside/#findComment-380566 Share on other sites More sharing options...
scooter41 Posted October 29, 2007 Author Share Posted October 29, 2007 ok I have found a more functional syntax: $encode_cmd = "lame -b 128 $source $target "; $output = exec($encode_cmd . ' 2>&1', $output, $return); echo $output; This it least gives me an output: running: sh: lame: command not found I guess I need to specify the full path to lame perhaps! Quote Link to comment https://forums.phpfreaks.com/topic/75225-solved-dynamic-mp3-compression-serverside/#findComment-380651 Share on other sites More sharing options...
scooter41 Posted October 29, 2007 Author Share Posted October 29, 2007 all sorted! had to install lame to a specific folder: in my case /usr/bin/lame/ Then called the full path to lame and it worked great! Quote Link to comment https://forums.phpfreaks.com/topic/75225-solved-dynamic-mp3-compression-serverside/#findComment-380695 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.