There are two established algorithms that can measure the faithfulness of video to its source. You have to input two video streams, the original source and the encoded version, and the algorithm calculates the faithfulness and outputs a figure.
Unfortunately for you, they both require you to supply the un-compressed source along with the compressed video, to do a comparison. There is no reliable algorithm to detect video quality that doesn't require the source.
PSNR is a very simple measure that just takes the difference in each pixel between the source and encoded version and averages out the squares of this difference across all pixels in all frames equally, arriving at a figure, which can be expressed as a "signal to noise ratio".
As video codecs became increasingly tuned psycho-visually, this algorithm became more and more irrelevant. Today, optimising a video codec for PSNR equates to optimising it to look badly. It is a very bad measure of how faithful to the source video actually looks to human eyes.
SSIM was created in large part due to these deficiencies in PSNR. It is a more complex algorithm that also takes into account how well the shape of structures in the resulting image correspond to structures in the source. This heavily biases against certain artefacts common in earlier block based compression (eg MPEG-2 as used in DVD) which includes blocking or ringing, artefacts that contribute a lot to our perception of the video quality even though their contribution to PSNR is lesser.
SSIM arrives at a figure indicating similarity, which can be converted to a ratio similar to PSNR.
As video codecs have evolved even further, SSIM now too has limitations, making it similarly unsuitable as a catch-all measure of video faithfulness. Modern video codecs such as h.264 do not have as much of a problem with blocking structures due to features such as in-loop deblocking and 4x4 transforms, whereas they do still suffer from loss of detail and noise (blurring), which is not well measured by SSIM.
There are other algorithms in existence, some of which claim to solve the deficiencies in these algorithms, but none of which have gained as much popularity.
Therefore, neither of these algorithms is a suitable way of measuring perceptual video quality. Instead, tuning video codecs requires a lot of observation: preferably, double-blind comparisons so that the observer can't be biased by knowing the codec in use: a feat that is difficult for video codecs which leave tell-tale signs unique to the codec even in fairly high bitrate compressed videos.