[FFmpeg-user] Frame counting is too slow
Peter White
peter.white at posteo.net
Tue Mar 9 23:21:33 EET 2021
On Tue, Mar 09, 2021 at 04:27:14PM +0100, Peter White wrote:
> Hi all,
>
> as a follow-up to this discussion:
> https://ffmpeg.org/pipermail/ffmpeg-user/2021-March/052358.html
>
> I would like to ask, if frame counting with ffprobe can be made faster.
> The way it done now is obviously by decoding every single frame and
> afterwards incrementing the counter. See how slow this example runs:
>
> time ffprobe -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 input.mkv
> [...]
> title : English
> BPS-eng : 72
> DURATION-eng : 00:21:36.169000000
> NUMBER_OF_FRAMES-eng: 370
> NUMBER_OF_BYTES-eng: 11676
> _STATISTICS_WRITING_APP-eng: mkvmerge v45.0.0 ('Heaven in Pennies') 64-bit
> _STATISTICS_WRITING_DATE_UTC-eng: 2021-02-16 19:59:37
> _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
> 31186
> ffprobe -count_frames -select_streams v:0 -show_entries stream=nb_read_frames 55,01s user 0,10s system 99% cpu 55,182 total
>
> And apparently ffprobe only uses one CPU core by default as opposed to
> ffmpeg; see the 99% load. This machine has 8 threads, hence is capable
> of 800%, theoretically. But that is just an aside.
FWIW, this last bit seems to be due to different defaults for ffprobe.
-threads 0 does show a load of 250% but the speedup is marginal, less
than 5 seconds.
Peter
More information about the ffmpeg-user
mailing list