In this post, we will see how to resolve Per second frame count using ffmpeg
Question:
I need to count the number of frames in a video captured by a camera on a per-second basis. I haven’t found a solution using ffmpeg or ffprobe (or something else) to output the number of frames per second (maintaining a constant frame rate is not guaranteed because of the capture mechanism and needs to be verified).So far, I’ve needed to run ffmpeg and ffprobe separately. First, I run ffmpeg to trim the video:
Best Answer:
Runffmpeg -report -i <in_video> -an -vf select='if(eq(n,0),1,floor(t)-floor(prev_selected_t))' -f null -
In the generated report, search for
select:1.000000
that will get you lines of the form
[Parsed_select_0 @ 000001f413152540] n:270.000000 pts:138240.000000 t:9.000000 key:0 interlace_type:P pict_type:P scene:nan -> select:1.000000 select_out:0
The
t
is the timestamp and the n
is the frame index. Check the frame index for each successive t
. The difference is the frame count for that 1 second interval.If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review