I need a fast and reliable way to get the total frame count of a video.
Here are the following methods that I have tried and their flaws:
ffprobe (fast way)
ffprobe -select_streams v:0 -show_entries stream=nb_frames -of default=noprint_wrappers=1 input.mp4
Problem: Often returns N/A, not reliable.
ffprobe (slow way)
ffprobe -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 input.mp4
Problem: Pretty slow, can take a minute for longer videos.
ffmpeg (fast way)
ffmpeg -i input.mp4 -map 0:v:0 -c copy -f null -
Problem: Needs to fully decode video once, which is rather slow
I know that what I'm looking for is possible because certain software (like Topaz Video Enhance) can do it. But I don't know how I can achieve this in my C# project or ffmpeg.