Psnr and ssim values generated by ffmpeg psnr filter are different from x264 tune psnr

encodingffmpegvideo

Currently,i'm focus on how to use psnr&ssim metrics to evaluate the video encode quality of libx264 and hw h264 encoders.

And i find that libx264 encoder has the option to log stuff psnr&ssim values.

When i use the following command,i can get the psnr when encode finish.

eg:ffmpeg -y -video_size 1920*1080 -pix_fmt yuv420p -r 25 -i
./Tennis_1920x1080_24.yuv -c:v libx264 -preset faster -tune psnr -vb
1000k -g 90 -s 1920*1080 -an libx264_out_1000k.h264 -psnr

[libx264 @ 0x4840c20] PSNR Mean Y:32.345 U:39.530 V:39.383 Avg:33.687 Global:33.326 kb/s:943.62

But sometimes the hardware encoder do not have the encode log,which should user the 3rd part tools to calculate the psnr quality.And i also find that when i use the ffmpeg psnr filter to caculate the psnr value,and i could not able the get the same score as the above result shows,even the encode frame is aligned.

ffmpeg -video_size 1920*1080 -pix_fmt yuv420p -r 25 -i
./Tennis_1920x1080_24.yuv -r 25 -i libx264_out_1000k.h264 -lavfi
psnr=stats_file=libx264_out_1000k.h264.log -f null – 2>&1 | tee
libx264_out_1000k.h264.ffmpeg_psnr.txt

[Parsed_psnr_0 @ 0x33b41e0] PSNR y:32.067442 u:39.500521 v:39.372329 average:33.447532 min:31.125177 max:37.774371

My question is that if we use the libx264 psnr value from its log ouput,and use the ffmpeg psnr filter to calculate the hw encode result,the different test tools will cause the different result.

During the video quality test,we should align the test tools.

So could anyone share some advise to me?And where can i get the psnr&ssim tools which could get the same test result as the libx264 log output?

Thanks in advance.

Best Answer

x264 calculate psnr of each frame and finally calculate the average psnr (psnr1 + psnr2 + ... psnrN) / frame_num, ffmpeg calculate mse of each frame and sum mse of all frames, then calculate the whole psnr for the sequence.

Related Question