Convert (or Extract) to MP3 using FFMPEG

article #316, updated 4636 days ago

To convert many formats to MP3, and to extract audio from many video formats to MP3 files, one may use FFMPEG:

ffmpeg -i sourcefile.xyz outputfile.mp3

A bash script to create an mp3 from every file in a folder, is thus:

#!/bin/bash
for sourcefile in *; do 
	ffmpeg -i "${sourcefile}" -ab 192k "${sourcefile}".mp3
done

Notice the “-ab 192k”. By default, ffmpeg seems to transcode to MP3 at 64k, regardless of input; this is not very high quality, whereas 192k does well for general use.

Categories: