0

I have a video that is setup like this:

$ mediainfo /mnt/d/Temp/VideoSamples/SampleVideo_1280x720_1mb.mp4

Video
...
Duration                                 : 5 s 280 ms
...

Audio
...
Duration                                 : 5 s 312 ms
...

The audio stream is a bit longer than the video stream. This is not an issue in most cases, however when we concat many such videos (say 20 of them or more) the audio and video are not in sync after a while.

So I'm thinking of pre-processing these files and make sure they all have the exact same audio and video stream duration, however I couldn't find any ffmpeg command to do this. Any idea how to achieve this?

  • 1
    This is actually pretty complicated. It depends on what audio codec is in use, and the samplerate of the audio. For example 44100 kHz aac produces 23 millisecond frames. (No longer, no shorter) so if your video frame rate is not a multiple of this, you may not have many options for the final duration. You can use pcm audio for more precision, but mp4 does not support pcm. Mkv does however. – SlimSCSI Oct 22 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.