When using labling tools, the count frame count by duration*fps, but for ffmpeg export, I get different frame count.
e.g.
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf61.1.100
Duration: 00:10:00.12, start: 0.017000, bitrate: 1509 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 1324 kb/s, 21.82 fps, 23.98 tbr, 24k tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 180 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
duration is 600.12, labling tool using fps 25 got 600.12 * 25=15003
frame count, but if I export to image
ffmpeg -i src/in.mp4 -vf fps=25 -q:v 2 tmp/frame_%05d.jpg
I got
frame=14985 fps=1139 q=2.0 Lsize=N/A time=00:09:59.40 bitrate=N/A dup=2 drop=0 speed=45.6x
600.12 * 25 - 14985 = 18
this cause some frame not match the label.
How can I get exact frame count by ffmpeg ? what cause the different ?
the ffmpeg export is time=00:09:59.40
, but ffprobe is Duration: 00:10:00.12
, about 0.72*25=18
, maybe this is the different , but I still don't know why this is different :<.
ffmpeg -i file.mkv -map 0:v:0 -c copy -f null -y /dev/null 2>&1 | grep -Eo 'frame= *[0-9]+ *' | grep -Eo '[0-9]+' | tail -1
seems to work. I've had the same issue withffprobe
.21.82 fps
. There is probably some timestamps inaccuracies in the input video. Remove-vf fps=25
(the framerate conversion filter). I don't think it's required, but try adding-fps_mode passthrough
. The number of JPEG images is going to be the number of frames, but probably not 600.12 * 25.600.12 * 25
frames, because the labeling tool detect as600.12 * 25
frames for a static 25fps, if the frame count not match , will cause the labeling mismatch.