[FFmpeg-user] RAW audio to MP3 via ffmpeg

Lou lou at lrcd.com
Tue Aug 23 03:22:49 CEST 2011


On Mon, 22 Aug 2011 21:04:30 -0400
James Lu <luj125 at gmail.com> wrote:

> On Mon, Aug 22, 2011 at 8:49 PM, Glau Stuff
> <glau.stuff at ridiculousprods.com>wrote:
> 
> > I've got a .raw audio file I'd like to convert to MP3 using ffmpeg.
> > I know that I could first convert it using sox with something like:
> >
> > sox -r 44100 -e unsigned -b 8 -c1 test_file.raw test_file.wav
> >
> > And then use ffmpeg to convert the WAV to MP3.
> >
> > But I want to skip a sox pass if I can and go straight to MP3.  Is
> > that possible? I saw mention of raw formats in the documentation
> > but not a set of
> > commands specific for audio (unless I missed it)
> > --
> > Phil
> 
> Hi Phil,
> 
> ffmpeg is really awesome, it should do any encoding you want. just go
> ahead and do what you think you should:
> 
> ffmpeg -i input.raw -acodec libmp3 output.mp3

-acodec libmp3lame

You may have to tell ffmpeg more about the raw input such as:

ffmpeg -f u16le -ar 44100 -ac 1 -i input.raw ...

> With encoding, you want to put in as many options as you can, so I
> suggest using -ab. Check the documentation for more commands

Often overlooked is -aq instead of -ab. Appropriate values for this
option depend on the encoder. With libmp3lame, this option is
equivalent to the -V option in lame. For a nice chart see:

<http://wiki.hydrogenaudio.org/index.php?title=LAME#Detailed_explanation_.28long_answer.29>

> Some tips:
> 1) use ffmpeg -formats and ffmpeg -codecs to check for which formats
> and codecs are available for your build of ffmpeg
> 2) for audio manipulations, sox and audacity are usually better
> alternatives, but ffmpeg has a much larger array of formats available.

SoX can be compiled to support MP3 encoding too.

> Hope this helps,
> ~James


More information about the ffmpeg-user mailing list