[FFmpeg-user] -codec copy creates incorrect duration when edit atoms are in input

Jesse Michael jesse.michael1234 at gmail.com
Thu Jun 6 00:46:25 EEST 2019


When using FFMPEG to `-codec copy` an input with [Edit Atoms] (https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-25579) before transcoding, the resulting output contains incorrect durations.

[mp4dump](https://www.bento4.com/documentation/mp4dump/) reveals a list of edit atoms for this [example mp4](https://drive.google.com/file/d/1Ql7BCz-EqCEBAxQ1G1nxfT8CWt_SogF3/view?usp=sharing) on the audio track.


{{{
...
    [edts] size=8+52
      [elst] size=12+40
        entry count = 3
        entry/segment duration = 111968
        entry/media time = 0
        entry/media rate = 1
        entry/segment duration = 111968
        entry/media time = 322560
        entry/media rate = 1
        entry/segment duration = 111968
        entry/media time = 645120
        entry/media rate = 1
...
}}}

using `ffmpeg version 4.1.3` and running
{{{
ffmpeg -i example.mp4 -codec copy example-copy.ts
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.3_1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'example.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2019-06-05T18:07:17.000000Z
  Duration: 00:00:22.03, start: 0.000000, bitrate: 862 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
    Metadata:
      creation_time   : 2019-06-05T18:07:17.000000Z
      handler_name    : Core Media Audio
    Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x360 [SAR 1:1 DAR 16:9], 760 kb/s, 30 fps, 30 tbr, 15360 tbn, 30720 tbc (default)
    Metadata:
      creation_time   : 2019-06-05T18:07:17.000000Z
      handler_name    : Core Media Video
      encoder         : H.264
Output #0, mpegts, to 'example-copy.ts':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    encoder         : Lavf58.20.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 760 kb/s, 30 fps, 30 tbr, 90k tbn, 15360 tbc (default)
    Metadata:
      creation_time   : 2019-06-05T18:07:17.000000Z
      handler_name    : Core Media Video
      encoder         : H.264
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
    Metadata:
      creation_time   : 2019-06-05T18:07:17.000000Z
      handler_name    : Core Media Audio
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
  Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654106, current: 564112; changing to 654107. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654107, current: 566202; changing to 654108. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654108, current: 568292; changing to 654109. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654109, current: 570382; changing to 654110. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654110, current: 572471; changing to 654111. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654111, current: 574561; changing to 654112. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654112, current: 576651; changing to 654113. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654113, current: 578741; changing to 654114. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654114, current: 580831; changing to 654115. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654115, current: 582920; changing to 654116. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654116, current: 585010; changing to 654117. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654117, current: 587100; changing to 654118. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654118, current: 589190; changing to 654119. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654119, current: 591280; changing to 654120. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654120, current: 593369; changing to 654121. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654121, current: 595459; changing to 654122. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654122, current: 597549; changing to 654123. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654123, current: 599639; changing to 654124. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654124, current: 601729; changing to 654125. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654125, current: 603818; changing to 654126. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654126, current: 605908; changing to 654127. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654127, current: 607998; changing to 654128. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654128, current: 610088; changing to 654129. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654129, current: 612178; changing to 654130. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654130, current: 614267; changing to 654131. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654131, current: 616357; changing to 654132. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654132, current: 618447; changing to 654133. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654133, current: 620537; changing to 654134. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654134, current: 622627; changing to 654135. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654135, current: 624716; changing to 654136. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654136, current: 626806; changing to 654137. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654137, current: 628896; changing to 654138. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654138, current: 630986; changing to 654139. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654139, current: 633076; changing to 654140. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654140, current: 635165; changing to 654141. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654141, current: 637255; changing to 654142. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654142, current: 639345; changing to 654143. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654143, current: 641435; changing to 654144. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654144, current: 643524; changing to 654145. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654145, current: 645614; changing to 654146. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654146, current: 647704; changing to 654147. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654147, current: 649794; changing to 654148. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654148, current: 651884; changing to 654149. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 654149, current: 653973; changing to 654150. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310169, current: 1220176; changing to 1310170. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310170, current: 1222265; changing to 1310171. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310171, current: 1224355; changing to 1310172. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310172, current: 1226445; changing to 1310173. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310173, current: 1228535; changing to 1310174. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310174, current: 1230624; changing to 1310175. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310175, current: 1232714; changing to 1310176. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310176, current: 1234804; changing to 1310177. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310177, current: 1236894; changing to 1310178. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310178, current: 1238984; changing to 1310179. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310179, current: 1241073; changing to 1310180. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310180, current: 1243163; changing to 1310181. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310181, current: 1245253; changing to 1310182. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310182, current: 1247343; changing to 1310183. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310183, current: 1249433; changing to 1310184. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310184, current: 1251522; changing to 1310185. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310185, current: 1253612; changing to 1310186. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310186, current: 1255702; changing to 1310187. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310187, current: 1257792; changing to 1310188. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310188, current: 1259882; changing to 1310189. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310189, current: 1261971; changing to 1310190. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310190, current: 1264061; changing to 1310191. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310191, current: 1266151; changing to 1310192. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310192, current: 1268241; changing to 1310193. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310193, current: 1270331; changing to 1310194. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310194, current: 1272420; changing to 1310195. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310195, current: 1274510; changing to 1310196. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310196, current: 1276600; changing to 1310197. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310197, current: 1278690; changing to 1310198. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310198, current: 1280780; changing to 1310199. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310199, current: 1282869; changing to 1310200. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310200, current: 1284959; changing to 1310201. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310201, current: 1287049; changing to 1310202. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310202, current: 1289139; changing to 1310203. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310203, current: 1291229; changing to 1310204. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310204, current: 1293318; changing to 1310205. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310205, current: 1295408; changing to 1310206. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310206, current: 1297498; changing to 1310207. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310207, current: 1299588; changing to 1310208. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310208, current: 1301678; changing to 1310209. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310209, current: 1303767; changing to 1310210. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310210, current: 1305857; changing to 1310211. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310211, current: 1307947; changing to 1310212. This may result in incorrect timestamps in the output file.
[mpegts @ 0x7fde3d80d400] Non-monotonous DTS in output stream 0:1; previous: 1310212, current: 1310037; changing to 1310213. This may result in incorrect timestamps in the output file.
frame=  661 fps=0.0 q=-1.0 Lsize=    2605kB time=00:00:21.96 bitrate= 971.5kbits/s speed= 952x
video:2046kB audio:282kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 11.917016%
}}}

and then running
{{{
ffmpeg -i example-copy.ts example-out.mp4
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.3_1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, mpegts, from 'example-copy.ts':
  Duration: 00:00:22.03, start: 1.433333, bitrate: 968 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 640x360 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 180k tbc
    Stream #0:1[0x101](und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 98 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7f9619001800] using SAR=1/1
[libx264 @ 0x7f9619001800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f9619001800] profile High, level 3.0
[libx264 @ 0x7f9619001800] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=11 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'example-out.mp4':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.35.100 aac
[aac @ 0x7f9619003000] Queue input is backward in time
[mp4 @ 0x7f961a81e800] Non-monotonous DTS in output stream 0:1; previous: 321536, current: 320513; changing to 321537. This may result in incorrect timestamps in the output file.
[aac @ 0x7f9619003000] Queue input is backward in time
[mp4 @ 0x7f961a81e800] Non-monotonous DTS in output stream 0:1; previous: 369666, current: 367533; changing to 369667. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f961a81e800] Non-monotonous DTS in output stream 0:1; previous: 369667, current: 368557; changing to 369668. This may result in incorrect timestamps in the output file.
[mp4 @ 0x7f961a81e800] Non-monotonous DTS in output stream 0:1; previous: 369668, current: 369581; changing to 369669. This may result in incorrect timestamps in the output file.
frame=  719 fps=556 q=-1.0 Lsize=     505kB time=00:00:23.86 bitrate= 173.3kbits/s dup=58 drop=0 speed=18.5x
video:354kB audio:124kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 5.579315%
[libx264 @ 0x7f9619001800] frame I:3     Avg QP: 5.93  size:   459
[libx264 @ 0x7f9619001800] frame P:318   Avg QP:20.39  size:   903
[libx264 @ 0x7f9619001800] frame B:398   Avg QP:18.68  size:   184
[libx264 @ 0x7f9619001800] consecutive B-frames: 15.6% 26.7% 15.4% 42.3%
[libx264 @ 0x7f9619001800] mb I  I16..4: 97.9%  1.8%  0.3%
[libx264 @ 0x7f9619001800] mb P  I16..4:  3.0%  5.6%  0.9%  P16..4:  5.2%  1.1%  0.8%  0.0%  0.0%    skip:83.4%
[libx264 @ 0x7f9619001800] mb B  I16..4:  0.8%  0.7%  0.0%  B16..8:  6.3%  0.4%  0.1%  direct: 2.0%  skip:89.6%  L0:53.8% L1:44.2% BI: 2.0%
[libx264 @ 0x7f9619001800] 8x8 transform intra:52.4% inter:40.4%
[libx264 @ 0x7f9619001800] coded y,uvDC,uvAC intra: 6.1% 19.9% 14.2% inter: 1.0% 3.3% 1.0%
[libx264 @ 0x7f9619001800] i16 v,h,dc,p: 82% 12%  5%  1%
[libx264 @ 0x7f9619001800] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 48% 11% 38%  1%  0%  0%  0%  0%  0%
[libx264 @ 0x7f9619001800] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 22% 32%  5%  3%  4%  3%  2%  2%
[libx264 @ 0x7f9619001800] i8c dc,h,v,p: 77% 10% 12%  1%
[libx264 @ 0x7f9619001800] Weighted P-Frames: Y:11.3% UV:10.4%
[libx264 @ 0x7f9619001800] ref P L0: 76.3% 10.8%  8.0%  4.4%  0.5%
[libx264 @ 0x7f9619001800] ref B L0: 68.4% 30.0%  1.6%
[libx264 @ 0x7f9619001800] ref B L1: 99.0%  1.0%
[libx264 @ 0x7f9619001800] kb/s:120.79
[aac @ 0x7f9619003000] Qavg: 46796.176
}}}
produces an output with a different duration than the input introducing A/V sync issues

input audio stream duration=21.868776

output audio stream duration=23.821769

I do see all the Non-monotonous DTS errors, but the issue in the output does not occur when skipping the `-codec copy` step and going straight to the transcode step (but this step is currently an important part of our workflow).

The issue also doesn't occur (for this example) when `-codec copy`ing to a different video container, like [.nut](https://ffmpeg.org/nut.html), but in other examples (specifically ones with a single edit atom entry with > 0 media_time) changing the video container doesn't solve the issue.

**Is FFMPEG ignoring/dropping the edit list when using the codec copy operation?**

**Is this the expected behavior or is there and issue with FFMPEG?**


More information about the ffmpeg-user mailing list