I want to compose many videos from frames and mp3 files then join them together using FFMPEG.

[frames+mp3] -> [Intermediate videos] -> [Joined intermediate videos]

Using mp4 with aac introduces noticeable audio gaps between videos when I use the concat protocol.

What are the best audio and video codes to be used for the intermediate videos? can this be done in a better way?

I'm a beginner in multimedia. Thanks a lot.

1 Answer 1


Mp4 with aac audio and h.264 video (mp4 isn't a codec as such, it's a container) isn't a good intermediate format. It is lossy, and the video is generally not all I-frame (meaning that to display a frame it references previous and following frames). h.264/aac/mp4 are great for delivery because they efficiently pack a lot of perceptual quality into a small file.

You're better off using an all-i-frame codec. Notable examples are Apple ProRes, Avid DNxHD and Cineform. These are all lossy, but minimally so. You can also use a lossless codec, like FFV1, but the speed and storage this requires might make it unworkable. Similarly you're best off using PCM (uncompressed) for your audio.

I'm not sure if that is going to affect the problem of the gaps. That might be an artefact of the way the video and audio are multiplexed.

  • 1
    For the purposes of concat via streamcopy, video codec doesn't really matter, as long as all files have the same codec properties. For audio, it is usually needed to have codecs without priming or remainder samples, so PCM will do. As will FLAC.
    – Gyan
    Commented Jul 22, 2019 at 9:53
  • Thank you Gyan FLAC saved the day. Just if anyone would ever need this, I converted mp3 -> pcm then wrote some code to remove the zeros at the begning of the PCM files, then converted the PCM to FLAC and used it (and applied a lowpass filter at 22k and concated everything) then it worked. (I needed FLAC because I use ffprobe to get audio duration and I didn't want to compute it after removing the extra samples)
    – shakram02
    Commented Jul 23, 2019 at 18:28

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.