How do I know if a video file is encoded perfectly or not?
There are several methods/algorithms to compare a transcoded file against its original. 

This is a good article which I believe covers what you're asking. It touches on algorithms such as Peak Signal-to-Noise (PSNR) ratio and Structural Similarity Index (SSIM) used to perform objective analysis -- without having to watch the actual video.

http://www.streamingmedia.com/Articles/ReadArticle.aspx?ArticleID=110206&amp;utm_source=RSS&amp;utm_medium=RSS&amp;utm_campaign=Article_Reads


  Without question, the gold standard for assessing video quality is a controlled subjective test, which, as previously mentioned, can be time-consuming and expensive to run. Objective quality benchmarks are algorithms that compare the compressed video with the source and render a value that predicts how the compressed file would fare in subjective tests. There are multiple algorithms, all rated according to how well they correspond with actual subjective evaluations. None are perfect, but some perform better than others.


Jan Ozer, the article author, even links to a demo of the Moscow University Video Quality Measurement Tool showing good and bad frame-to-frame comparisons.


                
            

Cheers,

Ian