title: FFmpeg is dropping a frame when converting MP4 to image sequence
body: <p>I have an MP4 file that's encoded at 12fps that I'm trying to convert to an image sequence using FFmpeg. The issue is that there is one frame missing. I've used the <a href="https://stackoverflow.com/a/28376817/3299349">solutions here</a> to confirm that the number of frames are 195 but when I run the following <code>ffmpeg -i video.mp4 frames_%04d.png</code>, I only get 194 PNGs. I've tried using the <code>-r 12</code> and <code>-framerate 12</code> flags but they do not change the output.</p>
  
  <p>I've also run the MP4 through Adobe Media Encoder to create an image sequence and that produces 195 frames. Any thoughts on to why I'm losing a frame?</p>
  
  <p>Edit - Logs added below</p>
  
  <p>Log from the command <code>ffmpeg -i video.mp4 frames_%04d.png</code>:</p>
  
  <pre><code>ffmpeg version 4.1.4 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.4_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.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
  [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fead5800000] st: 0 edit list: 1 Missing key frame while searching for timestamp: 0
  [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fead5800000] st: 0 edit list 1 Cannot find an index entry before timestamp: 0.
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 0
      compatible_brands: mp42mp41
      creation_time   : 2019-07-23T18:30:01.000000Z
    Duration: 00:00:16.25, start: 0.000000, bitrate: 957 kb/s
      Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 728x90, 953 kb/s, 12 fps, 12 tbr, 24k tbn, 24 tbc (default)
      Metadata:
        creation_time   : 2019-07-23T18:30:01.000000Z
        handler_name    : ?Mainconcept Video Media Handler
        encoder         : AVC Coding
  Stream mapping:
    Stream #0:0 -&gt; #0:0 (h264 (native) -&gt; png (native))
  Press [q] to stop, [?] for help
  Output #0, image2, to 'frames_%04d.png':
    Metadata:
      major_brand     : mp42
      minor_version   : 0
      compatible_brands: mp42mp41
      encoder         : Lavf58.20.100
      Stream #0:0(eng): Video: png, rgb24, 728x90, q=2-31, 200 kb/s, 12 fps, 12 tbn, 12 tbc (default)
      Metadata:
        creation_time   : 2019-07-23T18:30:01.000000Z
        handler_name    : ?Mainconcept Video Media Handler
        encoder         : Lavc58.35.100 png
  frame=  194 fps=0.0 q=-0.0 Lsize=N/A time=00:00:16.16 bitrate=N/A speed=52.1x    
  video:17552kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
  </code></pre>
  
  <p>Log from the command that I use that shows 195 frames <code>ffmpeg -i video.mp4 -map 0:v:0 -c copy -f null -</code></p>
  
  <pre><code>ffmpeg version 4.1.4 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.4_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.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
  [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f88f700b000] st: 0 edit list: 1 Missing key frame while searching for timestamp: 0
  [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f88f700b000] st: 0 edit list 1 Cannot find an index entry before timestamp: 0.
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 0
      compatible_brands: mp42mp41
      creation_time   : 2019-07-23T18:30:01.000000Z
    Duration: 00:00:16.25, start: 0.000000, bitrate: 957 kb/s
      Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 728x90, 953 kb/s, 12 fps, 12 tbr, 24k tbn, 24 tbc (default)
      Metadata:
        creation_time   : 2019-07-23T18:30:01.000000Z
        handler_name    : ?Mainconcept Video Media Handler
        encoder         : AVC Coding
  Output #0, null, to 'pipe:':
    Metadata:
      major_brand     : mp42
      minor_version   : 0
      compatible_brands: mp42mp41
      encoder         : Lavf58.20.100
      Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 728x90, q=2-31, 953 kb/s, 12 fps, 12 tbr, 24k tbn, 24k tbc (default)
      Metadata:
        creation_time   : 2019-07-23T18:30:01.000000Z
        handler_name    : ?Mainconcept Video Media Handler
        encoder         : AVC Coding
  Stream mapping:
    Stream #0:0 -&gt; #0:0 (copy)
  Press [q] to stop, [?] for help
  frame=  195 fps=0.0 q=-1.0 Lsize=N/A time=00:00:16.08 bitrate=N/A speed=1.13e+04x    
  video:1891kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
  </code></pre>