Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulty to validate odd meta (e.g. height moving back and forth from 816 to 818 regularly) #5

Closed
FitzWM opened this issue Jun 25, 2021 · 7 comments

Comments

@FitzWM
Copy link

FitzWM commented Jun 25, 2021

Hi, and let me say first, thanks for the great script. It certainly makes watching the Nolan Batman films significantly more enjoyable. I'd like to use it all the time, but unfortunately, it's failing for me on seemingly random files, no matter what options I change, even though the "traditional" autocrop.lua script seems to handle them fine. When I say failing, I mean that the script runs - I can see that in the stats screen - but it doesn't do anything, no matter how long or wait, skip around, or toggle it off and on. Changing modes doesn't help either, nor do turning off the "reset" or "skip" options, though I admit my understanding of those is less than minimal. I tried activating debug mode, but I couldn't figure out where to find the debug info; I'd be glad to provide it if you could tell me where it is.

The really annoying thing (since I'd like to provide a more useful bug report) is that there doesn't seem to be anything tying the "problem files" together. A few examples:

  • Kingdom of Heaven: Director's Cut - MakeMKV rip, x264, 1920x1080 video, actual 2.39:1 aspect ratio
  • Paprika - MakeMKV rip, MPEG-2, 1920x0180 video, actual 1:85:1 aspect ratio
  • Pirates of the Carribbean - MakeMKV rip, x264, 1920x1080 video, actual 2.39:1 aspect ratio
  • Zombieland - Handbrake encode, x264, 3840x2160 video, actual 2.39:1 aspect ratio

There are a couple others, but those are the ones I can recall right now. What's weird is that I have dozens of movies with exactly the same specs that all work just fine with your script. I can't figure out what the issue is. Obviously, the problem goes away if I run them through Handbrake and crop them, but that rather defeats the point of an autocrop script.

Anyway, thanks again, and I hope things are going well for you.

Edit: Forgot to add my specs.

  • Windows 10 Pro 21H1
  • mpv build mpv 0.33.0-177-gfd8c673cfc (x64)
  • AMD Ryzen 5800X CPU w/ 32 GB DDR4-3600c16 RAM
  • NVIDIA GTX 1080 Ti GPU (Driver version 471.11)
  • AOC AGON 34" 3440x1440 G-SYNC monitor
  • Latest version of the script, which I downloaded just a few days ago

I typically use the vulkan API and winvk context, along with the FSRCNNX and SSIMDownscaler shaders. I've tried turning all my shaders off, though, as well as changed to various APIs, but no luck.

@Ashyni
Copy link
Owner

Ashyni commented Jun 25, 2021

Hello, one thing to try quickly, would be to set deviation = 0, keep the rest with the default values, but the log will help to be sure what going on.

Edit mpv.conf :
log-file=C:\Users\<username>\AppData\Roaming\mpv\mpv.log -- Or any path you can find easily

Post me the log here or on pastebin, i'll take a look.

You can watch the log in realtime in powershell with Get-Content C:\Users\<username>\AppData\Roaming\mpv\mpv.log -Wait | Select-String -Pattern "\[dynamic_crop\]".

I also use FSRCNNX, KrigBilateral, SSSR, SSD with vulkan API, it's not an issue.

@FitzWM
Copy link
Author

FitzWM commented Jun 25, 2021

Thanks for the quick reply! I tried adding the script-opts-append=autocrop-deviation=0 option to mpv.conf, but it didn't seem to help, unfortunately. I've attached five files:

  • One mpv.log each for Kingdom of Heaven and Zombieland, with only dynamic-crop.lua installed (all defaults, except deviation=0)
  • Another set of mpv.logs with both dynamic-crop.lua and autocrop.lua, which I've modified not to auto-load and to use K as the shortcut, rather than C. I thought this might help figure out what's being done differently between the two scripts. I waited enough time for dyanmic-crop to have a chance to do its thing, and then ran autocrop manually, which worked for both movies. This is my current stopgap solution - using dynamic-crop most of the time and filling in with manual autocrop when it doesn't work.
  • My mpv.conf, just in case some option or other is causing problems

Just let me know if there's anything else I can do to help diagnose the issue.

kingdom-of-heaven.log
kingdom-of-heaven-autocrop.log
zombieland.log
zombieland-autocrop.log
mpv.conf.txt

@Ashyni
Copy link
Owner

Ashyni commented Jun 25, 2021

I have updated the documentation,

script-opts-append=autocrop-deviation=0

should be script-opts-append=<script_name>-<option>=<value>, e.g. script-opts-append=dynamic_crop-deviation=0, but it's not the issue anyway.

From the logs, with option debug=true (apparently), the collected meta found for Kingdom of Heaven

w=1920:h=822:x=0:y=126 | offX=0 offY=-3 | detected_total=8.05 ratio=nil -- 2,3357 compare to 1920/2.35=817+-1 (816 or 818 to match)
w=1920:h=820:x=0:y=128 | offX=0 offY=-2 | detected_total=1.752 ratio=nil 
w=1920:h=822:x=0:y=128 | offX=0 offY=-1 | detected_total=5.258 ratio=nil -- 2,3357
w=1920:h=824:x=0:y=126 | offX=0 offY=-2 | detected_total=0.917 ratio=nil 

and for Zombieland,

w=3840:h=1606:x=0:y=276 | offX=0 offY=-1 | detected_total=0.248 ratio=true 
w=3840:h=1608:x=0:y=276 | offX=0 offY=0 | detected_total=0.417 ratio=true 
w=3840:h=1604:x=0:y=278 | offX=0 offY=0 | detected_total=15.727 ratio=nil -- 2.39401 compare to 3840/2.39=1606.69+-1 (1606 or 1608 to match)
w=3840:h=1606:x=0:y=278 | offX=0 offY=1 | detected_total=0.835 ratio=true 

This show me that the collected meta is not match as known ratio, that's why the script doesn't approve the crop in 5sec (+1sec allowed to deviate) but should eventually be able to be approved as a fallback after 20sec (+1) in a stable light scene (which can be harder to get, but pass eventually).

I will work on something to get more tolerance on this, in the meantime you can adjust the list of ratios or reduce new_fallback_timer and increase deviation to 2 or 3 sec, e.g.
script-opts-append=dynamic_crop-new_fallback_timer=15, don't go to low, or you will end up with false positive crop
script-opts-append=dynamic_crop-deviation=2
script-opts-append=dynamic_crop-ratios={2.4, 2.394, 2.39, 2.35, 2.335, 2.2, 2, 1.85, 16 / 9, 5 / 3, 1.5, 4 / 3, 1.25, 9 / 16} -- doesn't work, i'm going to alter the format

@FitzWM
Copy link
Author

FitzWM commented Jun 26, 2021

OK, so good news and bad news. The good news is that simply adding the additional ratios seems to have solved the problem for Kingdom of Heaven, Zombieland, and Pirates of the Caribbean, in addition to the freshly merged Return of the King I just made. The bad news is that Kingdom of Heaven and Paprika continue to cause issues, even when I also added 2.347 to the list (basing that off the 1920x818 dimensions arrived at by autocrop for Kingdom). Oddly, as you said, both Kingdom and Paprika will eventually crop correctly once they hit that fallback of 20 seconds, or 15 if you edit. Can I ask what is done differently at that point that makes it work properly?

Also, I found that adding the options via script-opts-append in mpv.conf caused dynamic-crop to crash upon starting any file, but simply editing the options in the script itself worked fine. No idea why, but I thought I'd report it.

Edit: Even modifying the other parameters doesn't get those two to work properly. Very strange.

@Ashyni
Copy link
Owner

Ashyni commented Jun 27, 2021

Hello, multiple change that will help with your case have been made, give it a try.

Can I ask what is done differently at that point that makes it work properly?

Simple, new_known_ratio_timer is checked with the list of ratios and new_fallback_timer without it (all stable collected meta long enough)

I recommend avoiding added more ratio to the default list, to reduce the chance of a false positive cropping, and give time to the script to approve the first change of ratio.

You can speed up your test with ], reset with backspace.

Thanks for all the feedback.

Edit: bug fix in the meantime, be sure you have the latest version.

@Ashyni Ashyni changed the title Script fails on files where autocrop succeeds Difficulty to validate odd meta (e.g. height moving back and forth from 816 to 818 regularly) Jun 28, 2021
@FitzWM
Copy link
Author

FitzWM commented Jun 29, 2021

Hey, apologies for the late response. The fixes really seem to have helped! All but one of the movies I've tested now work as expected without further tweaking. Kingdom of Heaven, though, for whatever reason, simply refuses to crop normally, requiring the full new_fallback_timer period to expire before it will, finally, crop perfectly correctly. Maybe it's just something weird with that one file? In any case, everything else, across a few different aspect ratios and resolutions, seems to be working, so that's great! And I can always threaten the stubborn few with Handbrake...

@Ashyni
Copy link
Owner

Ashyni commented Jun 29, 2021

The log that you gave me for Kingdom of Heaven, show a 2.3357 aspect ratio, but the fallback timer is here for that.

You should try Interstellar with this script, it's a case of use where it shines.

I consider this case closed, Happy Video !

@Ashyni Ashyni closed this as completed Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants