Saved audio track is shorter than it should be

Started by tmcdos2, January 11, 2026, 05:12:32 PM

Previous topic - Next topic

tmcdos2

I have an MP4 video

=====================================================
Video
=====================================================
Codec 4CC:         H264
Image Size:         640 x 360
Aspect Ratio:         1:1 (1:1)
Frame Rate:         16.835 fps
Average Bitrate:      389 kbps
Total Duration:         00:09:20.369
Pixel format:         YUV 4:2:0, 8-bit
Color range:         Limited (MPEG)
Color primaries:      BT.709
Transfer characteristics:   BT.709
Color space:         BT.709

=====================================================
Video Codec Extradata
=====================================================
Size:            44
Extradata:         01 4D 40 16 FF E1 00 1D 67 4D 40 16 E8 80 50 17 FC B8 0B 50 10 10 14 00 00 03 00 04 00 00 03 00 88 3C 58 B4 48 01 00 04 68 EB 8F 20

=====================================================
Audio (1 active track(s))
=====================================================
Codec:            AAC
Channels:         Stereo
Bitrate:         15844 Bps / 126 kbps
Frequency:         44100 Hz
Total Duration:         00:09:20.451

-----------------------------------------------------
If I save the audio from AVIdemux - it is saved as AAC format and the audio length is 00:09:14.956
If I save the audio from VirtualDub - it is saved as WAV format and the audio length is 00:09:20.368
Why does not AVIdemux save the audio with correct length ?
If I simply save the audio and then immediately replace the audio track with the just saved file - audio and video go out of sync.
Is this a bug or a known issue which has a workaround (and what) ?
Observed behavior happens with all versions from 2.7.5 and up (I am using 2.8.2 build 241212_ce994de41a6-fflibs 7.0.2)

eumagga0x2a

Apologies for a very late reply.

Quote from: tmcdos2 on January 11, 2026, 05:12:32 PMIf I save the audio from AVIdemux - it is saved as AAC format and the audio length is 00:09:14.956

Do you dertermine audio length by actually listening to the AAC file to the end or by the estimate provided by a player application? The latter cannot be accurate for raw (ADTS encapsulated) variable bitrate AAC streams. When you save audio with the "PCM" audio encoder selected rather than "Copy", do you still miss a chunk of the audio?

Quote from: tmcdos2 on January 11, 2026, 05:12:32 PMIf I simply save the audio and then immediately replace the audio track with the just saved file - audio and video go out of sync.

Does the loss of sync develop gradually or stay constant (thus correctable by audio shift control in Avidemux)? Both scenarios are possible as video timing is given by timestamps in the container while the audio track was imported from a raw stream. If a small portion of audio track is damaged, that location will be missing in the saved raw audio stream.