I would like to calculate the SSIM for two videos by ffmpeg: the original video and the distorted video.

The case is the distorted video was generated by some kind of GPU of android devices, and it might miss some frames, for example, the original video has 720 frames, meanwhile the distorted one has 718.

Suppose we know the specific indices of the frames that was drop(For example, by calculating the MSE_U frame by frame), how to calculate the SSIM by ignoring some specific frames of the original video?

For example, we have know that the index 3 and index 717 was not exists in the distorted one, in order to SSIM, we should ignore these frames from the original one.

I've read the post Comparing PSNR/SSIM of two videos with different fps/bit-depth , drop similar frames and FFmpeg - dropping duplicate frames , it seems that they are not applying to my specific case.

1 Answer 1


Use the select filter to drop unwanted frames.

This is the basic syntax:

ffmpeg -i distorted -i ref -filter_complex "[0]settb=AVTB,setpts=N[ds];[1]settb=AVTB,select='not(eq(n\,3)+eq(n\,717))',setpts=N[rf];[ds][rf]ssim" -f null -

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.