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
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.
Post new comment