Basic Audio Transcoding options in FFmpeg

I hope you are now aware of the basic command format of ffmpeg. Now, I will tell you about some basic options/flags that can be used for audio transcoding.

-ar <value> This one is used to set the audio frequency of the output file. The comman values used are  22050, 44100, 48000 Hz.

-ac <value> Set the number of audio channels.

-ab <value> This flag is used to set the bitrate value of an audio file. e.g. you can use -ab 128k to use the 128kb bitrate. The higher the value, the better is the audio quality. This is one of the important factors responsible for the audio quality. But that doesn't mean you can make a poor audio file sound better by increasing its bitrate. The resultant file will just be of bigger size. You can find more about it in this audio compression howto.

-an This stands for "no audio recording" and can be used to strip out an audio stream from a media file. When you use this option, all the other audio related attributes are cancelled out.

-acodec This options lets you choose the type of audio codec you want to use. e.g. if you are using ffmpeg on a mp3 file, then it will need the audio codec libmp3lame. you can specify it using -acodec libmp3lame. Although, by default, ffmpeg should take care of the codecs you need(by guessing it from the output file format) and if you need anything different then go for this tag. So, a basic audio to audio conversion should be something like this.

[shredder12]$ ffmpeg -i input.wav output.mp3

In case you are not looking for a specific file format, then try and use open audio format ogg vorbis. It doesn't have any legal crap like patented mp3. You can use the following command to convert any audio file into ogg vorbis format.

[shredder12]$ ffmpeg -i input.mp3  -b 128k  output.ogg

This will directly convert your audio mp3 file into open format ogg file. You may also deliberately use the option "-acodec vorbis" in case it doesn't work.

3 Comments

Balwinder S Dheeman (not verified)
May 4th, 2010 01:29 pm
> The higher the value, the better is the audio quality. This is one of the > important factors responsible for the audio quality. You can find more > about it in this audio compression howto. Wrong, the quality of audio also depends on input file and, or recorded frequency. There nothing to gain, if the input file has a lower frequency, one may get fatter output file by increasing and, or transforming to higher frequencies instead.
May 4th, 2010 02:28 pm

Hello Balwinder,

I am sorry that I got you confused but I never said that converting a 128kb bitrate audio file to 256kb will increase the audio quality. I was making the reader aware of the terminology. But thanks for pointing it out, I guess this might be a point of confusion for other readers too. I have added your point in the post.

Pavel (not verified)
June 21st, 2010 08:39 am
It is not exactly true!!! Increasing the sampling rate will not increase the information content and the noise floor could also remain the same, provided a good sampling rate conversion technique is used. Hence we get a signal with higher sampling rate same SNR, same audio information content. But what is the use then?? The answer lies in the fact that the faith of every digital audio is a DAC. A higher sampled data is capable of producing analog signal with higher SNR and the audio can be perceived better. This comes from the reconstruction filter the DAC uses. A monotonic low order filter is used to achieve a high SNR value of about -120 db in practice. The reason a low order filter is used, because pass band ripples upto 20KHz (20Hz to 20KHz is considered audio though most people will not hear above 15KHz) is undesirable and lower filter orders are much more stable with physical parameters (temp. etc.) changing. Hence larger the transition band allowed for the filter, better the performance of the DAC. Also the DACs them selfs use delta sigma modulation based oversampled conversion technique, which gives higher SNR with higher oversampling ration. Hence in other words, a higher sampling rate ultimate delivers an analog signal with higher SNR.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Use syntax $$latex$$ to insert LaTeX formulas.
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.