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

Autocrop detect more pixels [BUG] #141

Closed
dravenar opened this issue Apr 10, 2023 · 3 comments
Closed

Autocrop detect more pixels [BUG] #141

dravenar opened this issue Apr 10, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@dravenar
Copy link

Hi! I've tested the autocrop feature, but it's giving me 4 more pixels (2 up/2 down) than the correct crop. For instance, despite giving me 138/138, it returns 140/140 (up/down). I've measure a screenshot in an online Photoshop like, and the correct value is 138 (also in other software like Handbrake/Hybrid). The film is Scream (2022).

1
2

Thank you very much for your software!

  • OS: Windows 10
  • NEAV1E Version: 2.1.14
@dravenar dravenar added the bug Something isn't working label Apr 10, 2023
@dravenar dravenar changed the title [BUG] Autocrop detect more pixels [BUG] Apr 10, 2023
@Alkl58
Copy link
Owner

Alkl58 commented Apr 16, 2023

Hey,
NEAV1E uses the crop detection of ffmpeg (cropdetect=24:16:0).

For that the most occuring detected value is selected:

string crop = cropList.Where(c => !string.IsNullOrEmpty(c)).GroupBy(a => a).OrderByDescending(b => b.Key[1].ToString()).First().Key;

I am not sure how I could fix that.

@dravenar
Copy link
Author

Hi, thank you very much for your response.

I have been looking on the internet for documentation on why the default values of ffmpeg in cropdetect are like this. But it seems that these values are based from past encode method, https://video.stackexchange.com/questions/15163/why-does-parameter-round-in-ffmpegs-cropdetect-default-to-16, when it seems that compressors used 16x16 blocks. Something that I do not think happens nowadays, in somple place, I've read that in the case of YUV 4:2:0, 2x2 blocks are used.

The problem with the round parameter is that if it has to be divisible by both width/height .

Set the value for which the width/height should be divisible by. The offset is automatically adjusted to center the video. Use 2 to get only even dimensions (needed for 4:2:2 video). 16 is best when encoding to most video codecs. Default value is 16.

Then, those values are more accurate if they are divisible by 2 than by 16. So maybe, cropdetect=24:2:0 is better than cropdetect=24:16:0, as suggested in https://www.reddit.com/r/ffmpeg/comments/kkvwl4/ffmpegs_cropdetect_output_vs_handbrakes_output/

In any case, I think that something that detects black lines should be conservative. It's better to preserve some pixels with black bars than to remove some pixels with information

@Alkl58
Copy link
Owner

Alkl58 commented Jan 28, 2024

Changed in the latest release.

@Alkl58 Alkl58 closed this as completed Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants