Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Hardware & Software > PC Hard & Software

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th July 2013, 14:21   #1  |  Link
DanielSB
Registered User
 
Join Date: Dec 2002
Posts: 18
Tool or plugin to detect effective visual resolution of a video?

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

Last edited by DanielSB; 7th July 2013 at 14:23. Reason: Spelling
DanielSB is offline   Reply With Quote
Old 7th July 2013, 15:54   #2  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
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 & 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.

Last edited by raffriff42; 7th July 2013 at 16:12.
raffriff42 is offline   Reply With Quote
Old 8th July 2013, 10:03   #3  |  Link
DanielSB
Registered User
 
Join Date: Dec 2002
Posts: 18
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
DanielSB is offline   Reply With Quote
Old 8th July 2013, 11:42   #4  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
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.
raffriff42 is offline   Reply With Quote
Old 8th July 2013, 11:50   #5  |  Link
DanielSB
Registered User
 
Join Date: Dec 2002
Posts: 18
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
DanielSB is offline   Reply With Quote
Old 9th July 2013, 02:28   #6  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
@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?
Code:
#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.

Last edited by raffriff42; 18th March 2017 at 01:38. Reason: (fixed image link)
raffriff42 is offline   Reply With Quote
Old 9th July 2013, 07:21   #7  |  Link
DanielSB
Registered User
 
Join Date: Dec 2002
Posts: 18
That's some darn nice lateral avisynth fu there, raffriff42!!!

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?
DanielSB is offline   Reply With Quote
Old 9th July 2013, 10:51   #8  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Quote:
Originally Posted by DanielSB View Post
That's some darn nice lateral avisynth fu there, raffriff42!!!
Thanks!

Quote:
Originally Posted by DanielSB View Post
I wonder if that could be automated in any way ... if one could like set a threshold...
Yeah, maybe. Something like that

Quote:
Originally Posted by DanielSB View Post
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.

Last edited by raffriff42; 9th July 2013 at 12:21.
raffriff42 is offline   Reply With Quote
Old 10th July 2013, 11:35   #9  |  Link
DanielSB
Registered User
 
Join Date: Dec 2002
Posts: 18
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!
DanielSB is offline   Reply With Quote
Old 14th July 2013, 10:49   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
@raffriff42

I dont really use masktools much but would not 2nd line below have less potential precision loss at the subtract stage.

Code:
  ## 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()
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 14th July 2013, 12:14   #11  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
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.
raffriff42 is offline   Reply With Quote
Reply

Tags
actual resolution, effective resolution, perceived resolution, resolution, scan

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:37.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.