Constant Frame Rate Video extracting more frames than expected – FFMPEG

I’m trying to extract 1 frame per second in a 3 second video that has a video frame rate of 30 fps.

ffmpeg -i 3seconds.mp4 -r 1 -q:v 2 output_%04d.jpg

I noticed that this command was returning 5 frames instead of 3. I then run this command to figure out that there are iframes in the video (not sure if thats the reason).

ffprobe -v error -select_streams v:0 -show_frames -show_entries frame=pict_type -of csv 3seconds.mp4

This may have been redundant but adding this filter flag gave me exactly 3 frames. Unclear about the underlying frame selection process.

ffmpeg -i 3seconds.mp4 -filter:v fps=1 -r 1 -q:v 2 output_%04d.jpg

Video info:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '3seconds.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.20.100 Duration: 00:00:03.07, start: 0.000000, bitrate: 2753 kb/s Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], 2747 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default) Metadata: handler_name : GoPro AVC vendor_id : [0][0][0][0] timecode : 19:56:41:04 Stream #0:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s Metadata: handler_name : GoPro AVC timecode : 19:56:41:04

Read more here: Source link