Answers.Body: <p>In this case, I can think of two possible causes. First is differing timebases for the video stream, which is definitely the case here. And second is unequal lengths of video and audio within each file. Unknown but unlikely since these are files produced by a camera.</p>
  
  <p>The reciprocal timebase for the video stream is reported as its <code>tbn</code> value.</p>
  
  <p>For the five files, they are <code>25k</code>, <code>24k</code>, <code>24k</code>, <code>24k</code> and <code>24k</code> respectively. The first one should be changed to 24k, else the videos streams of subsequent videos will be speeded up 4%, causing a desync.</p>
  
  <p>Normally, I would just rewrap the MP4, only changing the timescale. However, since PCM isn't supported in MP4 - the workaround here is to rewrap to MKV individually and then concat. Matroska files have a fixed timescale of 1000, so a simple command will do.</p>
  
  <pre><code>ffmpeg -i file.mp4 -c copy -dn file.mkv
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-12T14:54:12.897Z
Answers.Text: Answer: please see bottom (since there are too many characters to be posted here).
Answers.UserDisplayName: anuswara
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-12T08:31:13.093Z
Answers.LastActivityDate: 2019-05-12T08:31:13.093Z
Answers.UserDisplayName: Gyan
Answers.Body: <p>Wow Gyan, your are great!!!!</p>
  
  <p>I have to admit that I was not aware about the "small" difference in frequency 25 vs 24 = 1 tbn, and -concat can work only if all the files have exactly the same properties.</p>
  
  <p>I did what you suggested for each file individually</p>
  
  <p>ffmpeg -i a.mp4 -c copy -dn aaaaa.mkv
    ffmpeg -i b.mp4 -c copy -dn bbbbb.mkv
    ....
    ....</p>
  
  <p>then</p>
  
  <p>ffmpeg -hide_banner -f concat -safe 0 -i listaaaaa.txt -c copy concatenated.mkv</p>
  
  <p>Here the readout with some messages at the end:
  <a href="https://drive.google.com/open?id=1sdRHslop1r9Jb1yfx9DPhrCthRDz1kJl" rel="nofollow noreferrer">https://drive.google.com/open?id=1sdRHslop1r9Jb1yfx9DPhrCthRDz1kJl</a></p>
  
  <p>I can state that the final output (MKV) seems to me simply perfect!!!</p>
  
  <p>ffprobe says:</p>
  
  <blockquote>
    <blockquote>
      <p>start_time=0.000000&lt;&lt;</p>
    </blockquote>
  </blockquote>
  
  <p>MPC-HC/Audio says:</p>
  
  <blockquote>
    <blockquote>
      <p>Delay relative to video: -40 ms&lt;&lt;</p>
    </blockquote>
  </blockquote>
  
  <p>Super!
  You helped me very fine, my congratulations.
  I warmly thank you.
  Best,</p>
  
  <p>PS: I dont receive notification emails for replies hmmmmm</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-12T14:54:38.180Z
Answers.LastActivityDate: 2019-05-12T14:54:38.180Z
Answers.UserDisplayName: anuswara
Body: <p>I downloaded these files (at max resolution 4K, that is important), in this order:</p>
  
  <p><a href="https://vimeo.com/195782736" rel="nofollow noreferrer">https://vimeo.com/195782736</a>
  <a href="https://vimeo.com/196725716" rel="nofollow noreferrer">https://vimeo.com/196725716</a>
  <a href="https://vimeo.com/195776765" rel="nofollow noreferrer">https://vimeo.com/195776765</a>
  <a href="https://vimeo.com/196651176" rel="nofollow noreferrer">https://vimeo.com/196651176</a>
  <a href="https://vimeo.com/195781480" rel="nofollow noreferrer">https://vimeo.com/195781480</a></p>
  
  <p>please notice that these files are not "a video posted online" but the <strong>original output of a RX100m5</strong>!!</p>
  
  <p>each video offers:
  0:0 video
  0:1 audio
  0:2 "unknown to ffmpeg"</p>
  
  <p>therefore I changed the titles into
  a.mp4, b.mp4.......e.mp4
  to avoid the error. Amen.</p>
  
  <h2>Question:</h2>
  
  <p>I want to simply concatenate them, i.e. no recode!</p>
  
  <h2>Problem:</h2>
  
  <p>Sony's output is "MP4 = H264av1 + PCM". Curiously PCM is NOT supported by MP4 container (see official specs on wikipedia).
  Therefore ffmpeg is unable to do what I want. [It seems that Sony users never used ffmpeg].</p>
  
  <p>I tried:
  <code>ffmpeg -f concat -i lista.txt -c copy concatenated.mp4</code></p>
  
  <p>I got:</p>
  
  <pre><code>[mp4 @ 094630c0] Could not find tag for codec pcm_s16be in stream #1, codec not currently supported in container
  Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
  </code></pre>
  
  <p>as stated above Sony puts PCM into MP4 and this is not allowed.
  threfore I say let's to concatenate the files without recode/transcode and just change container:</p>
  
  <p><code>ffmpeg -f concat -safe 0 -i "lista.txt" -map 0:0 -map 0:1 -c copy concatenated.mkv</code></p>
  
  <p><code>ffmpeg -f concat -safe 0 -i "lista.txt" -c copy concatenated.mkv</code></p>
  
  <p>I got: no error message but...out of sync. that is unacceptable.
  [with MTS 1080p I simply concatenate them via the very very old Ts_splitter&amp;joiner.exe and all is fine and in sync!]</p>
  
  <h2>Addendum:</h2>
  
  <p>Only if I notice (like in the past!) that a simple "concatenate" let the Mb/s to drop down drastically, then I could add something like
  <code>-map "[v]" -map "[a]" -b:v 95000k</code>
  (that worked fine).</p>
  
  <p>thanks for a working string for the 5 videos :)
  ...I warmly hoping that the output will be in sync.</p>
  
  <p>best,</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-10T13:15:33.263Z
Comments.Text: Post the readout for `ffmpeg -i file1 -i file2 -i file3 -i file4`.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-10T15:48:12.107Z
Comments.Text: Here all the required complete readouts:  https://drive.google.com/file/d/1zORr4dB38_qtK4rsFpg-JkAOPwpJke53/view
Comments.UserDisplayName: anuswara
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-10T15:53:41.833Z
Comments.Text: Not using the concat list but the form in my command.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-10T16:03:37.777Z
Comments.Text: Even if I do not want to convert, here the required log, thanks: https://drive.google.com/open?id=1fP1JFM79xd_9hhHEA06SdrbbOkktM5hi
Comments.UserDisplayName: anuswara
Tags: <ffmpeg><mp4><sync><4k>
Title: Concatenating in sync MP4 (H264+PCM instead of AAC) from a Sony 2018 Camera
UserDisplayName: anuswara
ThreadText: # Concatenating in sync MP4 (H264+PCM instead of AAC) from a Sony 2018 Camera
  
  (Asked by: username_0 on 2019-05-10)
  
  I downloaded these files (at max resolution 4K, that is important), in this order:
  
  <https://vimeo.com/195782736>
  <https://vimeo.com/196725716>
  <https://vimeo.com/195776765>
  <https://vimeo.com/196651176>
  <https://vimeo.com/195781480>
  
  please notice that these files are not "a video posted online" but the **original output of a RX100m5**!!
  
  each video offers:
  0:0 video
  0:1 audio
  0:2 "unknown to ffmpeg"
  
  therefore I changed the titles into
  a.mp4, b.mp4.......e.mp4
  to avoid the error. Amen.
  
  ## Question:
  
  I want to simply concatenate them, i.e. no recode!
  
  ## Problem:
  
  Sony's output is "MP4 = H264av1 + PCM". Curiously PCM is NOT supported by MP4 container (see official specs on wikipedia).
  Therefore ffmpeg is unable to do what I want. [It seems that Sony users never used ffmpeg].
  
  I tried:
  `ffmpeg -f concat -i lista.txt -c copy concatenated.mp4`
  
  I got:
  
  ```
  [mp4 @ 094630c0] Could not find tag for codec pcm_s16be in stream #1, codec not currently supported in container
  Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
  
  ```
  
  as stated above Sony puts PCM into MP4 and this is not allowed.
  threfore I say let's to concatenate the files without recode/transcode and just change container:
  
  `ffmpeg -f concat -safe 0 -i "lista.txt" -map 0:0 -map 0:1 -c copy concatenated.mkv`
  
  `ffmpeg -f concat -safe 0 -i "lista.txt" -c copy concatenated.mkv`
  
  I got: no error message but...out of sync. that is unacceptable.
  [with MTS 1080p I simply concatenate them via the very very old Ts\_splitter&joiner.exe and all is fine and in sync!]
  
  ## Addendum:
  
  Only if I notice (like in the past!) that a simple "concatenate" let the Mb/s to drop down drastically, then I could add something like
  `-map "[v]" -map "[a]" -b:v 95000k`
  (that worked fine).
  
  thanks for a working string for the 5 videos :)
  ...I warmly hoping that the output will be in sync.
  
  best,
  
  **Tags:** ffmpeg, mp4, sync, 4k
  
  > **Comments:**
  > **username_1**: Post the readout for `ffmpeg -i file1 -i file2 -i file3 -i file4`.  
  > **username_0**: Here all the required complete readouts:  https://drive.google.com/file/d/1zORr4dB38_qtK4rsFpg-JkAOPwpJke53/view  
  > **username_1**: Not using the concat list but the form in my command.  
  > **username_0**: Even if I do not want to convert, here the required log, thanks: https://drive.google.com/open?id=1fP1JFM79xd_9hhHEA06SdrbbOkktM5hi  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-05-12. Score: 0 | Accepted answer
  
  In this case, I can think of two possible causes. First is differing timebases for the video stream, which is definitely the case here. And second is unequal lengths of video and audio within each file. Unknown but unlikely since these are files produced by a camera.
  
  The reciprocal timebase for the video stream is reported as its `tbn` value.
  
  For the five files, they are `25k`, `24k`, `24k`, `24k` and `24k` respectively. The first one should be changed to 24k, else the videos streams of subsequent videos will be speeded up 4%, causing a desync.
  
  Normally, I would just rewrap the MP4, only changing the timescale. However, since PCM isn't supported in MP4 - the workaround here is to rewrap to MKV individually and then concat. Matroska files have a fixed timescale of 1000, so a simple command will do.
  
  ```
  ffmpeg -i file.mp4 -c copy -dn file.mkv
  
  ```
  
  > **Comments:**
  > **username_0**: Answer: please see bottom (since there are too many characters to be posted here).  
  
  ---
  
  ### Answer by username_0 on 2019-05-12. Score: 0
  
  Wow username_1, your are great!!!!
  
  I have to admit that I was not aware about the "small" difference in frequency 25 vs 24 = 1 tbn, and -concat can work only if all the files have exactly the same properties.
  
  I did what you suggested for each file individually
  
  ffmpeg -i a.mp4 -c copy -dn aaaaa.mkv
  ffmpeg -i b.mp4 -c copy -dn bbbbb.mkv
  ....
  ....
  
  then
  
  ffmpeg -hide\_banner -f concat -safe 0 -i listaaaaa.txt -c copy concatenated.mkv
  
  Here the readout with some messages at the end:
  <https://drive.google.com/open?id=1sdRHslop1r9Jb1yfx9DPhrCthRDz1kJl>
  
  I can state that the final output (MKV) seems to me simply perfect!!!
  
  ffprobe says:
  
  > > start\_time=0.000000<<
  
  MPC-HC/Audio says:
  
  > > Delay relative to video: -40 ms<<
  
  Super!
  You helped me very fine, my congratulations.
  I warmly thank you.
  Best,
  
  PS: I dont receive notification emails for replies hmmmmm
  
  
  ---
  
  