Log in

View Full Version : How to calculate PSNR of video sequence in MP4 format.


Nasr
27th October 2010, 18:39
Hi,
I am using P2P streaming application which require input video in MP4 format and gives output in MP4 format.
Can anyone help me out how I can calculate the PSNR of received video in MP4 format.
I am used to YUV format but MP4 is new for me.
Any help will be highly appreciated.

Kind Regards

nm
27th October 2010, 19:02
YUV is raw video. You get that by demuxing and decoding the MP4 stream/file.

Nasr
28th October 2010, 12:44
Thank you very much for your reply.
Can you suggest me how to demux and decode MP4?

nm
28th October 2010, 13:16
Can you suggest me how to demux and decode MP4?

ffmpeg -i input.mp4 output.yuv

Or you could write an AviSynth script where you load the original and the received file and then use the Compare (http://avisynth.org/mediawiki/Compare) filter to calculate PSNR.

Nasr
28th October 2010, 16:50
Thanks again for your reply.
I tried interconversion from m4v to yuv and back again from yuv to m4v but the quality is not the same.
When I attractively repeat this process each time it gives a video with not the same quality because their relative PSNR varies.

Also can we use AviSynth under Linux?

AlekseiV
28th October 2010, 18:03
I tried interconversion from m4v to yuv and back again from yuv to m4v but the quality is not the same.
well, duh.

To go from MP4 -> YUV you are decoding to uncompressed. To go from YUV -> MP4 you are compressing it, which generally means quality loss.

nm
28th October 2010, 18:20
Thanks again for your reply.
I tried interconversion from m4v to yuv and back again from yuv to m4v but the quality is not the same.

Yep, changes in quality are determined by the bitrate (or compression factor), the encoder and it's parameters. It's also possible to store video losslessly in MP4 (with x264, for example), but then the amount of compression is limited. Definitely not suitable for streaming.

Also can we use AviSynth under Linux?

Yes, it's quite easy with Wine and avs2yuv (http://akuvian.org/src/avisynth/avs2yuv/) if you are on x86(-64). I use AviSynth and many complex filters all the time on Ubuntu.

Since you're using Linux, there's also a handy tool called qpsnr (http://qpsnr.youlink.org/) for PSNR and SSIM comparisons.

Nasr
29th October 2010, 19:00
Thank you very much! for such a detailed responses.

This information is indeed very helpful and have saved me lot of time.