0
votes

I download audio file and me need convert him on formats .mp3,.wav,.ogg.,acc. My script:

if($ext=='wav'){
    shell_exec("ffmpeg -i $infile -acodec libmp3lame -ab 320 $outfile_mp3");
    shell_exec("ffmpeg -i $infile -acodec libvorbis -ab 320 $outfile_ogg");
    shell_exec("ffmpeg -i $infile -acodec libfaac -ab 320 $outfile_aac");
}
elseif($ext=='mp3'){
    shell_exec("ffmpeg -i $infile -ab 256 $outfile_wav");
    shell_exec("ffmpeg -i $infile -ab 256 $outfile_ogg");
    shell_exec("ffmpeg -i $infile -ab 256 $outfile_aac");
    move_uploaded_file($tmp, $path.$name2.'mp3');
}
elseif($ext=='ogg'){
    shell_exec("ffmpeg -i $infile -acodec libmp3lame $outfile_mp3");
    shell_exec("ffmpeg -i $infile $outfile_wav");
    shell_exec("ffmpeg -i $infile -acodec libfaac $outfile_aac");
}
elseif($ext=='aac'){
    shell_exec("ffmpeg -i $infile -acodec libmp3lame $outfile_mp3");
    shell_exec("ffmpeg -i $infile -acodec libvorbis $outfile_ogg");
    shell_exec("ffmpeg -i $infile -acodec libmp3lame $outfile_wav");
}

Help me please convert files:

  1. how convert file in format .mp3 in formats .wav, .ogg, .acc
  2. how convert file in format .wav in formats .mp3, .wav, .acc
  3. how convert file in format .ogg in formats .mp3, .ogg, .acc
  4. how convert file in format .acc in formats .mp3, .ogg, .wav

I want to get good sound quality audio files...

1
And, what are you getting now?Brad
shell_exec("ffmpeg -i $infile -ab 256 $outfile_wav"); shell_exec("ffmpeg -i $infile -ab 256 $outfile_ogg"); shell_exec("ffmpeg -i $infile -ab 256 $outfile_aac"); not conver original file to need formats((John Smith
I checked all the directories are correctJohn Smith
shell_exec("ffmpeg -i $infile -ab 256 $outfile_aac"); not create good file(bad file with size 0 kb).John Smith
Make sure your ffmpeg commands work, and then attempt to script it. If you see the ffmpeg console output it will probably tell you why the file is "bad". Also, ffmpeg uses bits as a value for -ab, so you'll want to change -ab 320 to -ab 320k and same for 256.llogan

1 Answers

2
votes

first you need use '2>&1' in your code, example

shell_exec("ffmpeg -i $infile $outfile_wav 2>&1");

second, if you have error 'Unsupported codec for output stream' you need install libfaac.dll liblary for ffmpeg in your hosting.

Enjoy=)