Log in

View Full Version : Linux Command Line utility for comparing quality between media


spamalam
23rd September 2017, 16:12
Hi, I have a lot of video media I am archiving and often get duplicates. I'm looking to automate the process of determining which copy to keep by comparing the two copies, ensuring they are identical (ie. runtime, frames) and seeing which one has the better encoding (i.e. resolution, drf, interlacing vs progressive, cropping, audio sync, etc.).

I looked around for an appropriate tool, but they are mostly GUI based and don't make a decision.

The outcomes I would like is Archived is better than New, New is better than Archived, Media is different (i.e. different media) and unable to determine (i.e. requires manual validation).

I know there's a lot of complexity in this but I'm wondering if I can reduce most manual cases down.

Is there an application / script that can perform such analysis on two files?

poisondeathray
23rd September 2017, 21:10
Hi, I have a lot of video media I am archiving and often get duplicates. I'm looking to automate the process of determining which copy to keep by comparing the two copies, ensuring they are identical (ie. runtime, frames) and seeing which one has the better encoding (i.e. resolution, drf, interlacing vs progressive, cropping, audio sync, etc.).

I looked around for an appropriate tool, but they are mostly GUI based and don't make a decision.

The outcomes I would like is Archived is better than New, New is better than Archived, Media is different (i.e. different media) and unable to determine (i.e. requires manual validation).

I know there's a lot of complexity in this but I'm wondering if I can reduce most manual cases down.

Is there an application / script that can perform such analysis on two files?



Probably not, because there is no way to determine accurately or consistently what is "better" between 2 files . eg. Something might have a higher resolution, higher drf, higher bitrate, higher anything and yet be "worse" in quality. There is no good way to automate that type of detection with any accuracy

If you had a third file, the "original", then yes, you could probably run ssim/psnr metrics with ffmpeg for part of the script

Probably better off doing it yourself because there is way too much room for error

LoRd_MuldeR
23rd September 2017, 22:58
Probably not, because there is no way to determine accurately or consistently what is "better" between 2 files . eg. Something might have a higher resolution, higher drf, higher bitrate, higher anything and yet be "worse" in quality. There is no good way to automate that type of detection with any accuracy

If you had a third file, the "original", then yes, you could probably run ssim/psnr metrics with ffmpeg for part of the script

Probably better off doing it yourself because there is way too much room for error

Well, there exist different types of objective quality metrics. The most widely used ones (PSNR, SSIM, etc) indeed compute the "error" between a reference image/video and a modified (e.g. compressed) image/video – which means that a pristine quality "original" image/video is always required. But there also exist "blind" quality metrics that try to judge quality from a given image/video alone (no reference needed), e.g. by detecting certain "defects", such as blocking artifacts, noise, blurriness and so on... How well quality metrics of the latter kind approximate the "perceived" quality in practice is a completely different question, of course. But the same applies to non-blind metrics (PSNR, SSIM, etc) as well.

spamalam
24th September 2017, 20:02
I think a CLI that can provide blind metrics would be enough for a starting point, I think with that I can filter out most of the core defects and then rely on eyeballing them for validation.

I saw a very old tool called AVInaptic but it doesn't seem to compile/run on a modern linux distro and looks like its UI only?

LoRd_MuldeR
24th September 2017, 20:30
I saw a very old tool called AVInaptic but it doesn't seem to compile/run on a modern linux distro and looks like its UI only?

AFAIK, the tool "AVInaptic" only gives you the "technical characteristics" of the file (audio/video format, bitrate, quantizers, etc), but nothing that would allow you to judge the quality of the video. MediaInfo (https://mediaarea.net/de/MediaInfo) would be an alternative.

Plase don't make the mistake to judge quality by bitrate or by quantizer values! Higher bitrate (or lower quantizer) does not imply better quality: For example, the higher bitrate (or lower quantizer) encode may actually have been created from a worse source, so a lower bitrate (or higher quantizer) encode made from a higher quality source can actually look way better! Also, resulting quality depends a lot on the encoder used and the encoder's settings. A "bad" encoder can produce very poor quality, even if you crank up the bitrate! At the same time, a "good" encoder may produce decent quality at very low bitrates - from the exactly same source. Last but not least: Modern video formats, such as H.264, support a feature called "adaptive quantization", which means that every block in the frame can have its own separate quantizer. Usually, each block in a frame will store its quantizer as an offset from the frame's "base" quantizer. Consequently, tools that show you the frame quantizers - and that's what most tools do - will not tell you anything about the actual per-block quantizers. Not that the per-block quantizers would tell much about the video's actual quality, for the reasons explained before...