When extracting audio and video separately from a mp4 and recombining again

ffmpeg -accurate_seek -ss 30 -t 10 -i input.mp4 -vn output-audio.mp4
ffmpeg -accurate_seek -ss 30 -t 10 -i input.mp4 -an output-video.mp4
ffmpeg -i output-audio.mp4 -i output-video.mp4 output-combine.mp4

the three mp4-s have different length according to ffprobe:

ffprobe output-video.mp4
Duration: 00:00:10.00, start: 0.000000, ...
ffprobe output-audio.mp4
Duration: 00:00:10.03, start: 0.033333, ...
ffprobe output-combine.mp4
Duration: 00:00:10.08, start: 0.033333, ...

when combining audio and video with -shortest

ffmpeg -i output-audio.mp4 -i output-video.mp4 test-combine.mp4

the length is

ffprobe output-combine.mp4
Duration: 00:00:10.04, start: 0.033333, ...

How can the start-offset (0.033333) be avoided so that all parts have the same length and the original part can be restored by combining audio and video?

  • Share full log of ffmpeg -i input.mp4
    – Gyan
    Commented May 13, 2018 at 13:25

1 Answer 1


Correction: instead of

ffmpeg -i output-audio.mp4 -i output-video.mp4 test-combine.mp4

it should be

ffmpeg -i output-audio.mp4 -i output-video.mp4 -shortest output-combine.mp4

Kind of answer:

ffmpeg -i output-video.mp4 -itsoffset 0.033333 -t 9.966666 -i output-audio.mp4  output-combine.mp4

seems to do the job, although the result differs in file-size slightly from an direct extraction (direct is bigger than combine) done with

ffmpeg -accurate_seek -ss 30 -t 10 -i input.mp4 output-direct.mp4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.