Search code examples
ffmpegaac

Ffmpeg makes audio longer when changing bitrate


I've been using ffmpeg convert audio from one format to another and to change audio's bitrate. When I try to convert aac audio to mp3 audio using the command:

ffmpeg -i SomeAudio.aac -c:a mp3 -b:a 128k SomeOutputPath.mp3

everything works correctly and output audio is of the same length as the input audio (6 minutes, 15 seconds).

However, when I try converting it to aac audio using a similar command:

ffmpeg -i SomeAudio.aac -c:a aac -b:a 128k SomeOutputPath.aac

it makes the output audio longer (around 10 minutes). I have tried specifying output length but that still makes the video longer, it just cuts of part of the audio:

ffmpeg -i SomeAudio.aac -c:a aac -b:a 128k -t 00:06:15 SomeOutputPath.aac

Here is a link to the screenshot:

Changing aac bitrate

My suspicion is that message "Estimating duration from bitrate, this may be innacurate" (the one in the screenshot) is the root of my problem but I just haven't been able to find any useful information about it on the web.

Thanks a lot for any help in advance :)


Solution

  • The duration shown for raw AAC is a guess because it does not contain duration info. You can find the actual duration with:

    ffmpeg -i input.aac -f null -
    

    Or a faster, "close enough" method:

    ffmpeg -i input.aac -c copy -f null -
    

    Workaround is to remux to M4A:

    ffmpeg -i input.aac -c copy output.m4a