0

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 solutions here to confirm that the number of frames are 195 but when I run the following ffmpeg -i video.mp4 frames_%04d.png, I only get 194 PNGs. I've tried using the -r 12 and -framerate 12 flags but they do not change the output.

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?

Edit - Logs added below

Log from the command ffmpeg -i video.mp4 frames_%04d.png:

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 -> #0:0 (h264 (native) -> 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

Log from the command that I use that shows 195 frames ffmpeg -i video.mp4 -map 0:v:0 -c copy -f null -

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 -> #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
  • Share full log. – Gyan Jul 24 '19 at 04:45
  • Added the logs of the various outputs. – Phillip Dodson Jul 24 '19 at 17:10
  • I'm getting the same error (with timestamp: 2004) on some videos when calling the (x264) decoder directly via the libav API. In my case there seems to be a keyframe with pts=0, dts=-3003, which should be exported as the first frame; instead I get as the first out one that claims to have pts=0 but pkt_dts=0 too, and has the content of the next frame (pts=1001, dts=1001)! – BIOStheZerg Jan 24 '20 at 15:32
  • Hope this helps: In my case there was an edit list with a start pts of 2004, notice it's near but not at a frame boundary (which is at 2002). For some reason Adobe Premiere keeps the half-frame (or the 99.8%-frame) in, while our (libav-based) video decoder ignores the first (actually third!) frame... – BIOStheZerg Jan 27 '20 at 10:00

0 Answers0