<p>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.</p>

<p>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.</p>

<p>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.</p>

CC BY-SA 4.0
2019-07-22T09:53:02.980Z
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
CC BY-SA 4.0
2019-07-23T18:28:21.897Z
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
CC BY-SA 4.0
2019-07-22T04:43:05.133Z
2019-07-22T04:43:05.133Z
stib
<p>I want to compose many videos from frames and mp3 files then join them together using <code>FFMPEG</code>.</p>

<pre><code>[frames+mp3] -&gt; [Intermediate videos] -&gt; [Joined intermediate videos]
</code></pre>

<p>Using <code>mp4</code> with <code>aac</code> introduces noticeable audio gaps between videos when I use the <code>concat</code> protocol.</p>

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

<p>I'm a beginner in multimedia. Thanks a lot.</p>

<video><ffmpeg><audio>
What are the most mergeable codecs? What is the best codecs for intermediate videos?
shakram02
# What are the most mergeable codecs? What is the best codecs for intermediate videos?

(Asked by: username_0 on 2019-07-22)

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.

**Tags:** video, ffmpeg, audio


---

## 1 answers

### Answer by username_1 on 2019-07-22. Score: 3 | Accepted answer

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.

> **Comments:**
> **username_2**: 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.  
> **username_0**: Thank you username_2 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)  

---

