ffmpeg stops encoding after two frames - ffmpeg

I have a HEVC encoded 4k Video captured from a Reolink IP-Cam with VLC Player 3.0.14. I want to extract each frame of the video but the encoding stops after only two frames. This also happens when I try to convert into another video format.
This happens on Windows and Ubuntu with different ffmpeg versions.
My command is:
ffmpeg.exe -i vlc-record-2021-06-07-08h01m03s-rtsp___192.168.178.92_554_h265Preview_01_main-.mp4 output/%05d.jpg
The output is:
ffmpeg version 4.4.1-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11.2.0 (Rev1, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
[mov,mp4,m4a,3gp,3g2,mj2 # 000002a7960bc740] st: 1 edit list: 1 Missing key frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 # 000002a7960bc740] st: 1 edit list 1 Cannot find an index entry before timestamp: 0.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vlc-record-2021-06-07-08h01m03s-rtsp___192.168.178.92_554_h265Preview_01_main-.mp4':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: mp41avc1
creation_time : 2021-06-07T06:02:31.000000Z
playback_requirements: QuickTime 6.0 or greater
playback_requirements-eng: QuickTime 6.0 or greater
encoder : vlc 3.0.14 stream output
encoder-eng : vlc 3.0.14 stream output
Duration: 00:01:27.87, start: 0.000000, bitrate: 3175 kb/s
Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 16000 Hz, mono, fltp, 63 kb/s (default)
Metadata:
creation_time : 2021-06-07T06:02:31.000000Z
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Stream #0:1(eng): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv), 3840x2160, 3154 kb/s, 12.51 fps, 12.50 tbr, 1000k tbn, 1000k tbc (default)
Metadata:
creation_time : 2021-06-07T06:02:31.000000Z
handler_name : VideoHandler
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:1 -> #0:0 (hevc (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler # 000002a7a57f7d80] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'output/%05d.jpg':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: mp41avc1
encoder : Lavf58.76.100
playback_requirements: QuickTime 6.0 or greater
playback_requirements-eng: QuickTime 6.0 or greater
Stream #0:0(eng): Video: mjpeg, yuvj420p(pc, progressive), 3840x2160, q=2-31, 200 kb/s, 12.50 fps, 12.50 tbn (default)
Metadata:
creation_time : 2021-06-07T06:02:31.000000Z
handler_name : VideoHandler
vendor_id : [0][0][0][0]
encoder : Lavc58.134.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
frame= 2 fps=0.0 q=6.4 Lsize=N/A time=00:00:00.16 bitrate=N/A speed=0.197x
video:495kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Thanks for any help,
Maik

MP4s may have an edit list which tell the player to construct a virtual playback timeline. Occasionally, this timeline can leave out frames needed to decode stream correctly, or the sync samples table may be wrong.
Add -ignore_editlist to demux the stream without any edits.
ffmpeg.exe -ignore_editlist 1 -i vlc-record-2021-06-07-08h01m03s-rtsp___192.168.178.92_554_h265Preview_01_main-.mp4 output/%05d.jpg

Related

Wrong video duration and fps

I recorded a RTSP stream(4K) via VLC for about an hour and something odd happened.
The file size is 6.6 GB, but the video length is only 12 minutes long.
When I play it on VLC, the progress bar reaches the end, but the video still plays continuously.
Add to that, its FPS is 213, although playing speed is 30 FPS.
I tried below commands, but couldn't fix the issue.
$ ffmpeg -i <INPUT.mp4> -filter:v fps=fps=30 <OUTPUT.mp4>
// Only returns a 12 minutes long video
$ ffmpeg -vsync drop -i <INPUT.mp4> -map 0:v -vcodec copy output.mp4
// Crashes immediately
ffmpeg version 4.3.2-0york0~18.04 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr --extra-version='0york0~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libzimg --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0x55ed710400c0] st: 0 edit list: 1 Missing key frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 # 0x55ed710400c0] st: 0 edit list 1 Cannot find an index entry before timestamp: 0.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from <INPUT.mp4>:
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: mp41avc1
creation_time : 2021-11-20T01:02:54.000000Z
encoder : vlc 3.0.16 stream output
encoder-eng : vlc 3.0.16 stream output
Duration: 00:11:42.58, start: 0.000000, bitrate: 74723 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 74694 kb/s, 30.07 fps, 120 tbr, 1000k tbn, 60 tbc (default)
Metadata:
creation_time : 2021-11-20T01:02:54.000000Z
handler_name : VideoHandler
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: mp41avc1
encoder : Lavf58.45.100
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 74694 kb/s, 30.07 fps, 120 tbr, 1000k tbn, 1000k tbc (default)
Metadata:
creation_time : 2021-11-20T01:02:54.000000Z
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 # 0x55ed71043180] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
av_interleaved_write_frame(): Invalid argument
frame= 1 fps=0.0 q=-1.0 Lsize= 0kB time=-577014:32:22.77 bitrate=N/A speed=N/A
video:623kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
Although I couldn't restore the full file due to corrupted frames, I want to share the progress.
MP4Box supports changing the framerate without re-encoding
$ MP4Box -single 1 -raw 1 <INPUT_MP4_FILE>
It will return two files, <INPUT_MP4_FILE>_track1.mp4 and <INPUT_MP4_FILE>_track1.h264.
<INPUT_MP4_FILE>_track1.mp4 is a file with the correct fps and duration.
For my video, the file stops at 54:17 (the total length is 1:23:17),and I believe it's due to corrupted frames.
Reference

ffmpeg can't extract a frame near the end of the video

From what I gather, using ffmpeg to fully decode a video should give me an accurate duration. If I use:
ffmpeg -i my_vid.mov -f null -
for a particular video, I get an output of:
...
frame= 901 fps=0.0 q=-0.0 Lsize=N/A time=00:00:30.52 bitrate=N/A speed= 247x
...
But when I run the following command to extract a frame near the end, it fails:
ffmpeg -i my_vid.mov -ss 00:00:30.450 -q:v 2 -vframes 1 test_frame.jpg
outputs:
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Backing up to 00:00:30.000 with the ffmpeg command does get me a frame, however, and any time before that works as expected also. It seems like I should be able to get frames up to 00:00:30.520, though. What could be wrong here? Am I misreading the duration output?
Here is the full output I get from the frame extraction command:
> ffmpeg -ss 00:00:30.450 -i file_example_MOV_640_800kB.mov -q:v 2 -vframes 1 test_frame.jpg
ffmpeg version 2021-04-20-git-718e03e5f2-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 56. 73.100 / 56. 73.100
libavcodec 58.136.101 / 58.136.101
libavformat 58. 78.100 / 58. 78.100
libavdevice 58. 14.100 / 58. 14.100
libavfilter 7.111.100 / 7.111.100
libswscale 5. 10.100 / 5. 10.100
libswresample 3. 10.100 / 3. 10.100
libpostproc 55. 10.100 / 55. 10.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file_example_MOV_640_800kB.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf57.19.100
Duration: 00:00:30.57, start: 0.000000, bitrate: 208 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 60 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
vendor_id : FFMP
encoder : Lavc57.16.101 libx264
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 139 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler # 000001acc1d28580] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'test_frame.jpg':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.78.100
Stream #0:0(eng): Video: mjpeg, yuvj420p(pc), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : FFMP
encoder : Lavc58.136.101 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
frame= 0 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Here's the full output with copyts:
> ffmpeg -copyts -sseof -3 -i file_example_MOV_640_800kB.mov -q:v 2 -update 1 test_frame.jpg
ffmpeg version 2021-04-20-git-718e03e5f2-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 56. 73.100 / 56. 73.100
libavcodec 58.136.101 / 58.136.101
libavformat 58. 78.100 / 58. 78.100
libavdevice 58. 14.100 / 58. 14.100
libavfilter 7.111.100 / 7.111.100
libswscale 5. 10.100 / 5. 10.100
libswresample 3. 10.100 / 3. 10.100
libpostproc 55. 10.100 / 55. 10.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file_example_MOV_640_800kB.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf57.19.100
Duration: 00:00:30.57, start: 0.000000, bitrate: 208 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 60 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
vendor_id : FFMP
encoder : Lavc57.16.101 libx264
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 139 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
File 'test_frame.jpg' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler # 0000022d7e964480] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'test_frame.jpg':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf58.78.100
Stream #0:0(eng): Video: mjpeg, yuvj420p(pc, progressive), 640x360 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : FFMP
encoder : Lavc58.136.101 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
frame= 73 fps=0.0 q=2.0 Lsize=N/A time=00:00:00.00 bitrate=N/A speed= 0x
video:859kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
With an output seek, FFmpeg waits for the first keyframe after the seek point to start emitting frames.
Use an input seek,
ffmpeg -ss 00:00:30.450 -i my_vid.mov -q:v 2 -vframes 1 test_frame.jpg
To get the very last frame from a MOV/MP4 more generically, use
ffmpeg -sseof -3 -i my_vid.mov -q:v 2 -update 1 test_frame.jpg

Are there differences between the parameters of different versions of ffmpeg?

I want to obtain a different raw video for each frame of an MP4 file.
My instruction works in an old version of ffmpeg but not in the new one.
In the mp4 file there are 137 frames. It is checked. The versions are installed on different machines.
Versions 2.8.15:
$ ffmpeg -i ./video.mp4 -vf fps=30 -vframes 137 -vcodec rawvideo -s '1920x1080' -pix_fmt gray -threads 0 frame%08d.raw
ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: mp41mp42
creation_time : 2019-03-11 16:16:54
Duration: 00:00:04.57, start: 0.000000, bitrate: 14014 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 13816 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2019-03-11 16:16:54
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2019-03-11 16:16:54
Output #0, image2, to 'frame%08d.raw':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: mp41mp42
encoder : Lavf56.40.101
Stream #0:0(eng): Video: rawvideo (Y800 / 0x30303859), gray, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
Metadata:
creation_time : 2019-03-11 16:16:54
encoder : Lavc56.60.100 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame= 137 fps= 73 q=-0.0 Lsize=N/A time=00:00:04.56 bitrate=N/A dup=1 drop=0
video:277425kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Version 4.1.4:
$ ffmpeg -i ./video.mp4 -vf fps=30 -vframes 137 -vcodec rawvideo -s '1920x1080' -pix_fmt gray -threads 0 frame%08d.raw
ffmpeg version 4.1.4-1~deb10u1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
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 # 0x558d1a5bb880] st: 0 edit list: 1 Missing key frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 # 0x558d1a5bb880] 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 : isom
minor_version : 512
compatible_brands: mp41mp42
creation_time : 2019-03-11T16:16:54.000000Z
Duration: 00:00:04.57, start: 0.000000, bitrate: 14014 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 13816 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2019-03-11T16:16:54.000000Z
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2019-03-11T16:16:54.000000Z
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, image2, to 'frame%08d.raw':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: mp41mp42
encoder : Lavf58.20.100
Stream #0:0(eng): Video: rawvideo (Y800 / 0x30303859), gray, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 497664 kb/s, 30 fps, 30 tbn, 30 tbc (default)
Metadata:
creation_time : 2019-03-11T16:16:54.000000Z
encoder : Lavc58.35.100 rawvideo
frame= 136 fps= 25 q=-0.0 Lsize=N/A time=00:00:04.53 bitrate=N/A speed=0.834x
video:275400kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
In the latest version, I expect 137 files but the amount is 136.
The old version did not have support for edit lists. Technically, some frames are not meant for presentation but only as reference, but since you want all frames, use
ffmpeg -ignore_editlist 1 -i ./video.mp4 -vsync 0 -c:v rawvideo -s '1920x1080' -pix_fmt gray frame%08d.raw

ffmpeg lose frames when extracting them

When I extract all frames from a video, FFmpeg lose one frame. I tried multiple options, like adding more parameters to the function, but none of them worked.
ffmpeg -i Multicam420-30a.mp4 -framerate 30 frame%08d.jpg
ffmpeg version N-94077-g01d8c72b95 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190621
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 29.100 / 56. 29.100
libavcodec 58. 53.100 / 58. 53.100
libavformat 58. 28.100 / 58. 28.100
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 55.100 / 7. 55.100
libswscale 5. 4.101 / 5. 4.101
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0000023af91f9e80] st: 0 edit list: 1 Missing key frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 # 0000023af91f9e80] st: 0 edit list 1 Cannot find an index entry before timestamp: 0.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Multicam420-30a.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: mp41mp42
creation_time : 2019-08-20T01:30:57.000000Z
Duration: 00:00:01.00, start: 0.000000, bitrate: 11208 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 11007 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2019-08-20T01:30:57.000000Z
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2019-08-20T01:30:57.000000Z
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler # 0000023afb923740] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'frame%08d.jpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: mp41mp42
encoder : Lavf58.28.100
Stream #0:0(eng): Video: mjpeg, yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
Metadata:
creation_time : 2019-08-20T01:30:57.000000Z
encoder : Lavc58.53.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 29 fps= 17 q=24.8 Lsize=N/A time=00:00:00.96 bitrate=N/A speed=0.557x
video:3153kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
As you can see, the original video has 30 frames and last 1 second, and the output frames are 29 and less than a second.

ffmpeg mapping to mkv introduces "fake" delay relative to video

I need to map this x.264 clip into a matroska container using ffmpeg:
ffmpeg -i f-0.mp4 -c copy f-0.mkv
Here is the ffmpeg console output:
ffmpeg -i f-0.mp4 -c copy f-0.mkv
ffmpeg version N-69672-g078be09 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 18.100 / 54. 18.100
libavcodec 56. 21.102 / 56. 21.102
libavformat 56. 19.100 / 56. 19.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 9.104 / 5. 9.104
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'f-0.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.19.100
Duration: 00:02:08.06, start: 0.005333, bitrate: 5030 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4865 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 160 kb/s (default)
Metadata:
handler_name : SoundHandler
Side data:
unknown side data type 7 (4 bytes)
Output #0, matroska, to 'f-0.mkv':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.19.100
Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 4865 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 30k tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 160 kb/s (default)
Metadata:
handler_name : SoundHandler
Side data:
unknown side data type 7 (4 bytes)
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
...
The result seems good, playing with well synchronized audio and video. However, MediaInfo shows a new item under Audio (that the original clip didn't have):
Delay relative to video : 1mn 5s
Here is the Mediainfo from the original f-0.mp4 file:
Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : ac-3
Duration : 2mn 8s
Bit rate mode : Constant
Bit rate : 160 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Delay relative to video : 67ms
Stream size : 2.44 MiB (3%)
Mediainfo from the f-0.mkv output:
Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : A_AC3
Duration : 2mn 8s
Bit rate mode : Constant
Bit rate : 160 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Delay relative to video : 1mn 5s
Stream size : 2.44 MiB (3%)
Default : Yes
Forced : No
HANDLER_NAME : SoundHandler
There is no delay whatsoever and no reason to insert a delay.
I am concerned that this information (Delay relative to video) be used by some players or other applications as a delay that should be corrected. Is there a way to prevent this from happening?
Adding ffprobe output: f-0.mp4 clip
ffprobe -show_entries stream=codec_type,duration,start_time -of compact f-0.mp4
ffprobe version N-69672-g078be09 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 18.100 / 54. 18.100
libavcodec 56. 21.102 / 56. 21.102
libavformat 56. 19.100 / 56. 19.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 9.104 / 5. 9.104
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'f-0.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.19.100
Duration: 00:02:08.06, start: 0.005333, bitrate: 5030 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4865 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 160 kb/s (default)
Metadata:
handler_name : SoundHandler
Side data:
unknown side data type 7 (4 bytes)
stream|codec_type=video|start_time=0.000000|duration=128.061267
stream|codec_type=audio|start_time=-0.005333|duration=128.064000
f-0.mkv clip:
ffprobe version N-69672-g078be09 Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 18.100 / 54. 18.100
libavcodec 56. 21.102 / 56. 21.102
libavformat 56. 19.100 / 56. 19.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 9.104 / 5. 9.104
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, matroska,webm, from 'f-0.mkv':
Metadata:
COMPATIBLE_BRANDS: isomiso2avc1mp41
MAJOR_BRAND : isom
MINOR_VERSION : 512
ENCODER : Lavf56.19.100
Duration: 00:02:08.13, start: 0.061000, bitrate: 5026 kb/s
Stream #0:0(und): Video: h264 (High), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
Metadata:
LANGUAGE : und
HANDLER_NAME : VideoHandler
Stream #0:1(und): Audio: ac3, 48000 Hz, stereo, fltp, 160 kb/s (default)
Metadata:
LANGUAGE : und
HANDLER_NAME : SoundHandler
stream|codec_type=video|start_time=0.066000|duration=N/A
stream|codec_type=audio|start_time=0.061000|duration=N/A

Resources