How to calculate the PSNR of video sequence?

11 views (last 30 days)
Hi there,
I want to calculate the PSNR value between two videos. One video is original and another one is watermarked video. The watermarked video has some watermarked frame. I have calculated PSNR of each frame one at a time of both of the videos, and calsulate the average of it, but unfortunately I get the "Inf" value of PSNR.
Again, I have also tried to calculate the PSNR of exactly two videos. As a result, I got the PSNR of 40 dB. In fact, the result must be 99.99
Any help must be appreciated.
Thanks in advance.
The code I have written to calculate the PSNR of two idential videos
clc;
output_folder = 'D:\Matlab book and files\SLT\Akiyo_frames_journal';
vidObj1 = VideoReader('akiyo_cif_x264.mp4');
vidObj2 = VideoReader('akiyo_cif_x264_Copy.mp4');
EnumFrames=0;
Extframe = cell(1,300) ;
frame = cell(1,300) ;
numFrames1 = 0;
numFrames2 = 0;
while hasFrame(vidObj1)
F1 = readFrame(vidObj1);
numFrames1 = numFrames1 + 1;
frame{numFrames1} = F ;
numFrames1
while hasFrame(vidObj2)
F2 = readFrame(vidObj2);
numFrames2 = numFrames2 + 1;
Extframe{numFrames2}=F2;
end
numFrames2
for i= 1:300
Extframe{i}= getframe;
frame{i}= getframe;
fprintf ("The PSNR of frame %d = %.2f \n", i , psnr(frame2im(Extframe{i}),frame2im(frame{i})))
end
OUTPUT
The PSNR of frame 1 = Inf
The PSNR of frame 2 = Inf
The PSNR of frame 3 = Inf
The PSNR of frame 4 = Inf
The PSNR of frame 5 = Inf
The PSNR of frame 6 = Inf
The PSNR of frame 7 = Inf
The PSNR of frame 8 = Inf
The PSNR of frame 9 = Inf
The PSNR of frame 10 = Inf
............................................
.............................................
............................................
The PSNR of frame 300 = Inf

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!