View Full Version : Tool or plugin to detect effective visual resolution of a video?
DanielSB
7th July 2013, 14:21
Hi :)
I've been wondering about this for awhile with regards to ripping Blu-Ray content to something smaller and more portable.
Often, especially with older color film shot up to about the late nineties, ripping them to 1080p is pointless, as the source is way too soft to give you that amount of actual detail (save for noise, which sometimes is nice enough to keep). Sometimes it seems that even 720p would be wasted on them (like with really cheap 8mm productions, or just low-grade equipment and lenses).
It'd seem reasonable to resize these videos to whatever their actual effective optical resolution is before encoding them to whatever target I'm going for. What that resolution exactly is, however, can be pretty tricky to determine. Even if you sample yourself to something that seems reasonable in one scene, it might not be representative of the entire film. Some scenes might be shot under better conditions, at a different aperture, using better equipment, etc.
So I'm wondering if there exists some kind of tool or plugin that's able to scan a video source for visual resolution, sort of like a media player might scan your tracks for volume levels.
I find it pretty difficult to search for on Google — so now I'm asking here, where so many experts hang out :)
Hope to hear something positive from you :)
Thanks in advance,
Daniel
raffriff42
7th July 2013, 15:54
It's an interesting question, but - there is little benefit to resizing before compression. Softer sources will automatically compress better, whatever their resolution (DCT transform ('http://en.wikipedia.org/wiki/Discrete_cosine_transform#Multidimensional_DCTs') & quantization takes care of that - if there is no information at a given spatial frequency, no bits are needed to encode it). Not taking noise into account, as you mention.
DanielSB
8th July 2013, 10:03
Interesting. I've noticed how really undersized rips will tend to just "reduce resolution" until they look pretty much like your average DVD rip or worse (e.g. a YIFI "1080p" rip). I'm guessing it's the same mechanism kicking in there?
But, besides the noise aspect (which I assume would mean I'd have to use some kind of (temporal) noise filter, which I'd rather not), I find it difficult to believe that it can really be as effective at reducing the bitrate to "accommodate" the bit usage on the basis of effective resolution? Also, how well does that mechanism deal with high vs. low motion scenes?
Looking at other's encodes that are shared in both 720p and 1080p where the source material is really soft, the size difference can oftentimes be 100% while offering close to zero visual difference (provided that your player uses a good scaling algorithm such as Lanczos or Spline — if not, you'll notice the curves being slight less smooth (and sharp) on the 720p version). On some occasions, indeed, I find that the 720p version is actually the better looking one.
Thanks,
Daniel :)
raffriff42
8th July 2013, 11:42
OK I made a sweeping generalization there - sorry about that. For instance, at very low bitrates - 0.5 MB/s - resizing can help tremendously. A full size, high motion, low bitrate video might be an unwatchable mass of macroblocks, where the same video downsized might look blurry, but good otherwise.
DanielSB
8th July 2013, 11:50
NP :) I'm learning here. BTW, that Wikipedia link is hard on my brain ;)
I believe I get your points, though, but nonetheless I'm still interested if knowing if such a tool or filter exists.
If not, well, so be it :)
Cheers,
Daniel
raffriff42
9th July 2013, 02:28
@DanielSB, here's something - it isn't a tool yet, it's more of a toy - but this script compares a resized video to the original.
* If you can make out the picture in the difference image, you are losing valuable information.
* OTOH if the difference looks random, you aren't losing anything significant.
I don't know if this can be boiled down to a simple "go / no go" test...anyone?
#avisynth
## open source:
A=DirectShowSource("path to video")
A=A.ConvertToYV12(matrix="PC.709") ## Full range
## test resize:
B=A.Spline36Resize(640, 360)
## restore to original size (for comparison w/ original)
B=B.Spline36Resize(A.Width, A.Height)
## optional crop for 1280x720 final output:
A=A.Crop(0, 0, 512, 360)
B=B.Crop(0, 0, 512, 360)
C=mt_lutxy(A, B, "x y - abs").Greyscale() ## /v2
A=A.Levels(0, 1.0, 255, 16, 235)
B=B.Levels(0, 1.0, 255, 16, 235)
return StackHorizontal(
\ StackVertical(
\ A.Subtitle("orig"),
\ B.Subtitle("resized")),
\ StackVertical(
\ C.Tweak(bright=15).Histogram().Subtitle("diff"),
\ C.mt_lut("x 4 *").Tweak(bright=12).Histogram().Subtitle("diff x 4")))
This (extremely sharp) example image was resized to 50% - the loss is pretty bad by my books.https://www.dropbox.com/s/0alc5zov2yda98w/resize-diff4f.jpg?raw=1
DanielSB
9th July 2013, 07:21
That's some darn nice lateral avisynth fu there, raffriff42!!! :D
I wonder if that could be automated in any way? Like, the amount of white would appear to be the level of details lost. So, if one could like set a threshold and have the script exit with an error if it goes above that threshold?
I'm not quite sure on how to actually understand the output, though... What's the first "diff" image, for instance?
raffriff42
9th July 2013, 10:51
That's some darn nice lateral avisynth fu there, raffriff42!!! :DThanks!
I wonder if that could be automated in any way ... if one could like set a threshold...Yeah, maybe. Something like that :confused:
I'm not quite sure on how to actually understand the output, though... What's the first "diff" image, for instance?It represents what has changed between the original image and the processed image. It's almost* what you would see if you opened an image in Photoshop/GIMP/Paint Shop Pro etc >> duplicate as new layer >> do something to the dupe layer like soften >> set merge/overlay mode to "difference."
This is a trick I use all the time when working with images, and I wanted an Avisynth script to do the same thing. It uses MaskTools' mt_lut because that's what I was reading about at the time :)
The second diff image exaggerates the first by 4x to make the changes more visible.
* Overlay(mode="subtract").Tweak(bright=16) is actually closer to Photoshop; the mt_lut method I show might be "better" because of the "absolute value" term. It shows all differences, where the Overlay/Photoshop method "hides" the negative-going diffs.
DanielSB
10th July 2013, 11:35
Aahh! So the first diff is the diff from resizing, and the second one is the same diff, but exaggerated?
I sort of "read it" from left to right and saw #2 diff as the actual diff created, so I was wondering how there could be a diff on the original image, I wanted it to be all black :)
That's not a whole lot of difference, though, considering the visual difference between the two. It'll be fun to actually try this on a source from a soft BluRay at 1080p vs. 720p!
Thanks again, man, it's really cool! :)
StainlessS
14th July 2013, 10:49
@raffriff42
I dont really use masktools much but would not 2nd line below have less potential precision loss at the subtract stage.
## rejigger Subtract() to show diff as absolute value:
#C=Subtract(A, B).Greyscale().mt_lut("128 x - abs")
C=mt_lutxy(A,B,"x y - abs").Greyscale()
raffriff42
14th July 2013, 12:14
Absolutely, it would! Thank you. I'm barely acquainted with MaskTools myself, but yes, it'd be better to do all arithmetic in floats. Compared to yours, my version has many ±1 errors and a few pixels off by ±3. Comparison was made after correcting my LUT to "127 x - abs" [oops.gif]
I'll update the script with your change. Thanks again.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.