0

Here is what I did with "original.mp4" (00:15:22 duration, ~80MB filesize):

  1. Extracted video stream from mp4

    ffmpeg -i original.mp4 -c copy -an vid_only.mp4

  2. Extracted audio stream from mp4

    ffmpeg -i original.mp4 -vn -acodec copy aud_only.aac

  3. Merged the extracted audio and video streams to form new mp4

    ffmpeg -i aud_only.aac -i vid_only.mp4 new_mix.mp4

And found that "new_mix.mp4" was mixed accurately, duration was same as before, but the file-size had dropped to 36MB (from ~80MB). Using ffprobe on both "original.mp4" and "new_mix.mp4", I found that the difference is in bitrate of the audio and video streams.

Step #1 and #2, extracted the audio and video streams without any reencoding. Step #3, supposedly merged audio and video streams, but took quite a long time, so probably performed reencoding. Is that right ? And if so, is there a way to tell ffmpeg to not reencode while merging, to do it faster and retain original bitrate ?

2

-c copy tells ffmpeg to streamcopy all streams being processed. That's missing.

ffmpeg -i aud_only.aac -i vid_only.mp4 -c copy new_mix.mp4

Also, for step 2, it's better to extract to a container like M4A

ffmpeg -i original.mp4 -vn -acodec copy aud_only.m4a

If your audio has timestamp gaps, .aac will lose them.

  • Thanks. This answer has a very crucial bit of information about timestamp gaps in aac, and why it is better to use m4a container. No wonder, none of the tools could tell the duration of the audio clip as .aac ! – icarus74 May 21 '18 at 17:12
0

Okay, my bad. Looks like the answer was only a search away. Mods may mark the question as duplicate. Here is what I needed to do to achieve the original file-size, and retain the original (higher) bitrates, i.e. merge audio + video streams without reencoding (thus much faster):

`ffmpeg -i aud_only.aac -i vid_only.mp4 -acodec copy -vcodec copy mixed_copy.mp4`

Here's the original Q&A here on this site: How to merge audio and video file in ffmpeg

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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