edoceo

Encode / Change Encoding of Audio Files with PHP

Using ffmpeg from within PHP

// Here file is uploaded and then the name is stored in 
//	$file_i = input file name
//	$file_o = output file name

$ffmpeg_bin = '/usr/bin/ffmpeg';
$ffmpeg_audio_opt = '-acodec mp3 -ab 192 -ac 2 ';
$ffmpeg_video_opt = '-acodec mp3 -ab 192 -ac 2 ';


// Audio Conversion
$cmd = $ffmpeg_bin . $ffmpeg_audio_opt . '-i ' . shellescapearg($file_i) . ' ' . shellescapearg($file_o);
// $cmd = "/usr/bin/ffmpeg -i $uploadFile -f flv -acodec mp3 -ab 64 -ac 1 -title \"Clip Title\" -author \"Clip Author\" -copyright \"Clip Copyright\" $finalFile";
exec( $cmd );

// Video Conversion
$cmd = $ffmpeg_bin . $ffmpeg_video_opt . '-i ' . shellescapearg($file_i) . ' ' . shellescapearg($file_o);
exec( $cmd );




unlink( $uploadFile );

chmod( $finalFile, 0644 );

Loading Comments from Disqus...