Basics of the Issue
The current algorithm looks for the median size of black edges from the picture preview scans you see in the Summary tab, judging from previous forum discussions. The difficult tradeoffs here are real: a weak cropping algorithm would encode empty data and increase the risk of artifacts, while an aggressive cropping algorithm loses content. More sophisticated algorithms would be difficult to implement and test, and might hang.
While there's no perfect answer, judging from the frequency of over cropping to cropping artifact posts on the forums, taking the median value might not be the right compromise for most users. I personally worry more about losing content than introducing an artifact, because I can always shave off another column of pixels, but it's impossible to add back lost content unless I've also preserved the original source.
Possible Improvements
First, add a toggle in advanced preferences that could tweak the algorithm between two settings:
- Automatic (the balanced CURRENT BEHAVIOR)
- Conservative (looks for the MINIMUM safe value to crop across all frames, to tolerate a higher risk of artifacts but ensure no lost content)
As a fallback, I would also increase the default sample frames slightly, even just to 15.
I'm less sure, but we might want to bring that option out from advanced settings and place it on the Summary tab next to the preview frames. People seem to not realize that option exists, but cluttering the main UI is risky. It might be easiest to educate users about the impact of that setting in the advanced preferences tab. In advanced preferences, directly beneath "Number of picture previews to scan:" we could add a comment:
(This setting will affect the accuracy of automatic cropping.)
Finally, I would also consider an offset for the very first preview sample frame by a few seconds. Often for films the Hollywood studio logo will appear and provide a good bright reference frame 3-5 seconds into the content. Right now the current preview sample frame is often completely black before the fade in, so it doesn't contribute useful information, visually to the user, or to the cropping algorithm. Not all content is a studio film, so this may be a hasty generalization, but it seems unlikely to worsen the first sample for most content.
Any thoughts on which option above would be the most effective? Any other ideas on even better ways to improve this balance?
Additional Reading
Back in Feb, rollin_eng recommended increasing picture preview scans to improve autocrop behavior:
viewtopic.php?f=7&t=38760&p=182822#p182823
In 2015, JohnAStebbins wrote:
viewtopic.php?f=6&t=31519HandBrake detects where these black bars are by sampleing several frames throughout the video and looking for the median values for the width of the bars. So if the width varies somewhat over the length of the movie, you will see some frames overcropped and some undercropped by a few pixels. There is no "best" fix for this scenario.