How to change the audio sample rate using FFmpeg?

I have a lossy AAC audio file and I would like it to be high quality while still keeping the lossy encoding. Is there any way I can change the sample rate of the audio file using FFmpeg?

1 Like

Hey Komal,

In order to change the audio sample rate using FFmpeg, the -ar option in FFmpeg can be used. The quantity of audio samples recorded per second is determined by the audio sample rate. The audio quality, file size, and compatibility with various hardware and applications can all be impacted by changing the sampling rate.

Here is how to adjust the audio sample rate step-by-step:

ffmpeg -i input.mp3 -ar 44100 output.mp3

  • The input audio file input.mp3 and the desired output file output.mp3 are used in the example above.
  • 44100 is the intended sample rate (in this case, 44.1 kHz), while -ar indicates the sample rate to be utilized.
  • The relevant file names and directories for your case can be used in place of input.mp3 and output.mp3.
  • Furthermore, you can change the sample rate (in the example, 44100) to the required amount.

Keep in mind that altering the audio sample rate can degrade the sound or create artifacts. It is advised to select a sample rate that is suitable for your individual requirements and the features of the audio source.

Additionally, You can use FFmpeg’s other audio-related options, including -ac to adjust the number of audio channels and -ab to adjust the audio bit rate, in addition to the -ar option. You can mix and match these settings to get the output audio that best suits your requirements.

For example, if you need to alter the sample rate and the quantity of audio channels.

Do checkout this for more:

1 Like

How do I determine the audio rate to use in FFmpeg?

Most likely, 44100 for the audio sample rate and 128 for the bit rate will be adequate.

For examples of sampling rate and audio bit rate settings that are appropriate for what you’re attempting to do, consult Wikipedia.

1 Like

So, is there a command that I can run immediately to check?

Yes, to find out the sample rate and bitrate of the audio stream in the source video.avi, use ffmpeg -i video.avi

With the same sample rate and bitrate, the audio stream can be retrieved without reducing the quality.

You can choose to decrease one of them to make it smaller, but don’t increase one of them to make it better because you can never improve the original quality.

Personally, for Avi and Mpeg video files, I use the -ar 22050 and -ab 48 switches. It functions normally.

How can I modify the sample rate while maintaining the original audio format?

1 Like

In order o replicate the audio codec without re-encoding, use the -c:a copy option:
ffmpeg -i inputfile.mp3 -c:a copy -ar 44100 outputfile.mp3

To prevent data loss, always create a backup of your original files before carrying out any conversion. Consider checking the output quality as well to make sure it satisfies your requirements.

1 Like

If so then, will the audio quality change if the sample rate is changed?


Yes, if you’re resampling to a lower rate, adjusting the sample rate may have an impact on the audio quality. Although increasing the sampling rate could result in larger files, it might not dramatically enhance quality.

1 Like