How to Use ffmpeg to convert MP4 and other formats to MP3 format

Single conversion

command

ffmpeg -i {input file} {output file}

Example

Mp4 to MP3

ffmpeg -i foo.mp4 foobar.mp3

flv 转 mp3

ffmpeg -i foo.flv foobar.mp3

mp4 transfer wav

ffmpeg -i foo.mp4 foobar.wav

wav transfer mp3

ffmpeg -i foo.wav foobar.mp3

Batch conversion

For example, there are *. MP4 files under the folder. To batch convert them to XX. MP3 files, you can use the following methods

for i in ./*.mp4
do
ffmpeg -i $i ${i}.mp3
done

For another example, all files under the folder should be converted into XX. MP3 files in batch. You can use the following methods

for i in ./*
do
ffmpeg -i $i ${i}.mp3
done

Connect two videos

ffmpeg -i "concat:1.ts|2.ts" -acodec copy -vcodec copy -absf aac_adtstoasc output.mp4

Multiple audio merging

ffmpeg.exe -i "concat:1.mp3|2.mp3" -acodec copy output.mp3

Read More: