I need to convert audio files to mp3 using ffmpeg.
When I write the command as ffmpeg -i audio.ogg -acodec mp3 newfile.mp3
, I get the error:
<
Try FFmpeg Static Build Link
Documentation: https://www.johnvansickle.com/ffmpeg/
Host the static build on your server in same directory
$ffmpeg = dirname(__FILE__).'/ffmpeg';
$command = $ffmpeg.'ffmpeg -i audio.ogg -acodec libmp3lame audio.mp3';
shell_exec($command);
I had to purge my ffmpeg and then install another one from a ppa:
sudo apt-get purge ffmpeg
sudo apt-add-repository -y ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg
Then convert:
ffmpeg -i audio.ogg -f mp3 newfile.mp3
1) wav to mp3
ffmpeg -i audio.wav -acodec libmp3lame audio.mp3
2) ogg to mp3
ffmpeg -i audio.ogg -acodec libmp3lame audio.mp3
3) ac3 to mp3
ffmpeg -i audio.ac3 -acodec libmp3lame audio.mp3
4) aac to mp3
ffmpeg -i audio.aac -acodec libmp3lame audio.mp3
For batch processing with files in folder aiming for 190 VBR and file extension = .mp3 instead of .ac3.mp3 you can use the following code
Change .ac3 to whatever the source audio format is.
ffmpeg mp3 settings
for f in *.ac3 ; do ffmpeg -i "$f" -acodec libmp3lame -q:a 2 "${f%.*}.mp3"; done
For batch processing files in folder:
for i in *.wav; do ffmpeg -i "$i" -f mp3 "${i%}.mp3"; done
This script converts all "wav" files in folder to mp3 files and adds mp3 extension
ffmpeg have to be installed. (See other answers)
High quality for Mac OS works perfectly!
ffmpeg -i input.wma -q:a 0 output.mp3