Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Posted at http://www.w3tools.info/2011/09/php-lame-encoder-mp3-conversion.html */
- function alterBitrate($data,$filefrom,$fileto,$lamepath){
- /*
- $data = array holding data related to mp3.
- $filefrom = Mp3 file path.
- $fileto = Path to save file to
- $lamepath = Path to lame encode
- */
- $tagncmd = array(
- 'br' => '-b',
- 'title' => '--tt',
- 'artist' => '--ta',
- 'album' => '--tl',
- 'comment' => '--tc',
- 'genre' => '--tg',
- 'art' => '--ti',
- 'year' => '--ty',
- 'trackno' => '--tn'
- );
- $execstr = escapeshellarg($lamepath);
- foreach($data as $k => $v){
- if($v!="")
- $execstr .= " ".$tagncmd[$k]." ".escapeshellarg($v);
- }
- $execstr .= " ".escapeshellarg($filefrom)." ".escapeshellarg($fileto);
- echo $execstr;
- echo system($execstr);
- }
- /* USAGE */
- $data = array(
- 'br' => 50, // Bitrate
- 'title' => 'Something',
- 'artist' => 'Someone',
- 'album' => 'Somealbum',
- 'comment' => 'Altering Bitrate :P',
- 'genre' => 'Rock',
- 'art' => 'art.gif',
- 'year' => '2011',
- 'trackno' => '5'
- );
- alterBitrate($data,'F:\php\lame\samp.mp3','F:\php\lame\new.mp3','F:\php\lame\lame.exe');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement