[FFmpeg-user] Frame count mismatch after generating proxy file

Mike Grishaber MGrishaber at merlinone.com
Wed Nov 23 05:17:37 EET 2022


Hello All,

I am using FFMpeg to generate a down-sized proxy video for downstream processing.
I am piping the video into FFMpeg as a stream and piping the resulting proxy video directly back to the calling application as a stream.
In order to do this I use the '-movflags frag_keyframe+empty_moov' option in order to place the 'moov' atoms to the start of the stream.
This all works fine, however the downstream process that uses the proxy video is throwing an error because the frame count in the proxy video does not match the frame count defined in the file's metadata.
In order to verify this, I ran the following FFMpeg command to export the individual frames of the proxy video to a sub-directory.

ffmpeg -i proxy_video.mp4 frames/$filename%03d.bmp

I then count the number of frames generated as follows.
ls frames | wc -l

For my small sample video this gives me a count of 167.

I then used FFProbe to get the number of frames for the video as follows.
ffprobe -v error -select_streams v:0 -count_frames -show_entries stream=nb_read_frames proxy_video.mp4

For the same video I get a count of 165.
Looking at the original video there are indeed 165 frames, and looking at the bmp files generated for the proxy, it appears that two extra frames are added at the start.
The two extra frames are not a problem, but the count of actual frames vs frames defined in metadata must match.

Is there a way I can update the frame count in the header, or possibly a way to prevent the generation of the extra frames?

The FFMpeg command I am running is as follows.
ffmpeg -i test_video.mp4 -acodec libmp3lame -vcodec libx264 -r 30 -vf scale=480:-2 -f mov -movflags frag_keyframe+empty_moov proxy_video.mp4

The output from my FFMpeg  version is as follows, and the full console dump is attached.

ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
  built with Apple clang version 14.0.0 (clang-1400.0.29.102)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/5.1.2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100

Thank you for your help
Mike
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ffmpeg_dump.txt
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20221123/c8757985/attachment.txt>


More information about the ffmpeg-user mailing list