How to measure frame decoding using ffmpeg?

[What I've done]

I am trying to measure the performance of various ffmpeg decoders on

  • specify how long the function call avcodec_decode_video2(..)takes ffmpeg.c and runs the ffmpeg binary as follows.

~/bin/ffmpeg -benchmark_all -loglevel debug -threads 0 -i ~/Documents/video-input.h264 -c:v libx265 -x265-params crf=25 video-output.hevc

  • and by determining the time during which the same function executes ffplay.c and runs the ffplay binary file as follows.

~/bin/ffplay ~/Documents/video-input.h264

In my understanding, the average time for calling this function should be the same, whether it is video conversion or its playback, because I only measure how much time it takes to decode the frame for this video. Is this the wrong way to do this? Please let me know if I am wrong. The results that I get are strange for me - calling the above function takes twice as much in the ffmpeg binary as compared to the ffplay binary. I tried to run the ffmpeg binary with -threads 0and without it, but the results are still the same (twice as long as ffplay). Maybe because the ffplay binary just uses more threads? When I try to use it with-threads 1ffmpeg takes about 10 times as much as ffplay (which makes sense to me since it hasn't used multiple threads, and now it uses only 1)

Before asking your question, I want you to know that I am new to video processing and video encoding / decoding.

[My question]

I am wondering what would be the exact way to measure how long it takes to decode a frame (using 1 stream)? Should I just measure how long it takes to call the function avcodec_decode_video2(..)using the ffmpeg binary and not the ffplay binary? Will the result be more accurate? I also tried including parameters -benchmark_all -loglevel debug, but it seems that the following message is bench: 64537 decode_video 0.0not very useful if 0.0 means time. (Not sure what another number means).

+4
1

Null muxer

, null muxer:

ffmpeg -i input -f null -

Linux macOS time:

$ time ffmpeg -i input -f null -
[...]
real    0m5.343s
user    0m20.290s
sys     0m0.230s

. man time.

-benchmark

-benchmark :

$ time ffmpeg -i input -f null -
[...]
bench: utime=7.314s
bench: maxrss=72280kB

, :

ffmpeg -i input -map 0:a:0 -f null -

, :

ffmpeg -threads 1 -i input -f null -

, - . , ffmpeg -h decoder=h264.

. , :

ffmpeg -c:v vp8 -i input -f null -
ffmpeg -c:v libvpx -i input -f null -
+9

All Articles