Auto cropping crops too much

HandBrake for Windows support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
Silent_Strider
Enlightened
Posts: 102
Joined: Tue Dec 17, 2019 9:31 pm

Auto cropping crops too much

Post by Silent_Strider »

Description of problem or question:
Upon encoding some DVD extras from Jurassic Park, HB (again) crops the hell out of some videos and I don't see the reason why.

Here is an image of 20 frames throughout the movie.
https://i.imgur.com/jkMDLDx.jpg

In this 20 frames, frames 3, 6, 19 and 20 definitely do not have a black border to the bottom.
Various other frames have digital black border
Various other frames have noisy black background

Trying to find an average crop is.... bad in my opinion. I'd love to see an option, where you can switch between various crop algorithms.
E.g. one which really only crops digital back, another one going for a treshold and so on.

Steps to reproduce the problem (If Applicable):
For me it has happened on various video clips. Most often it's Making Of's, which have movie material with black borders in between, then full image sequences of people talking or computer dialogs shown how the scenes were created. This more often would remove 140 pixels from bottom and top from those full screen scenes. Setting the number of picture previews to 60 does not help the slightest.

HandBrake version (e.g., 1.0.0):
1.3.1 (2020010400)

Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):
Windows 10 Professional

HandBrake Activity Log:

Code: Select all

HandBrake 1.3.1 (2020010400)
OS: Microsoft Windows NT 10.0.18363.0
CPU: AMD Ryzen 9 3900X 12-Core Processor            
Ram: 32720 MB, 
GPU Information:
  NVIDIA GeForce GTX 980 - 26.21.14.3630
Screen: 2560x1440
Temp Dir: C:\Users\Ezatoka\AppData\Local\Temp\
Install Dir: C:\apps\video\HandBrake
Data Dir: C:\Users\Ezatoka\AppData\Roaming\HandBrake

-------------------------------------------


# Starting Encode ...

[12:16:46] base preset: Unreferenced (Modified)
[12:16:46] hb_init: starting libhb thread
[12:16:46] Starting work at: Wed Feb 12 12:16:46 2020
[12:16:46] 1 job(s) to process
[12:16:46] CPU: AMD Ryzen 9 3900X 12-Core Processor
[12:16:46]  - logical processor count: 24
[12:16:46] Intel Quick Sync Video support: no
[12:16:46] hb_scan: path=C:\!media\DVD\Jurassic Park\Jurassic Park III\Extras\A Visit to ILM\Muscle Simulation\Demonstration.mkv, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
src/libbluray/disc/disc.c:323: failed opening UDF image C:\!media\DVD\Jurassic Park\Jurassic Park III\Extras\A Visit to ILM\Muscle Simulation\Demonstration.mkv
src/libbluray/disc/disc.c:424: error opening file BDMV\index.bdmv
src/libbluray/disc/disc.c:424: error opening file BDMV\BACKUP\index.bdmv
src/libbluray/bluray.c:2585: nav_get_title_list(C:\!media\DVD\Jurassic Park\Jurassic Park III\Extras\A Visit to ILM\Muscle Simulation\Demonstration.mkv\) failed
[12:16:46] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.1
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[12:16:46] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from 'C:\!media\DVD\Jurassic Park\Jurassic Park III\Extras\A Visit to ILM\Muscle Simulation\Demonstration.mkv':
  Metadata:
    encoder         : libmakemkv v1.14.7 (1.3.5/1.4.7) win(x64-release)
    creation_time   : 2020-02-11T22:47:30.000000Z
  Duration: 00:01:44.48, start: 0.000000, bitrate: 4749 kb/s
    Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv, top first), 720x576 [SAR 16:15 DAR 4:3], 25 fps, 25 tbr, 1k tbn, 50 tbc
    Metadata:
      BPS-eng         : 4537911
      DURATION-eng    : 00:01:44.480000000
      NUMBER_OF_FRAMES-eng: 2612
      NUMBER_OF_BYTES-eng: 59265123
      SOURCE_ID-eng   : 0100E0
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-11 22:47:30
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      title           : Stereo
      BPS-eng         : 192000
      DURATION-eng    : 00:01:44.448000000
      NUMBER_OF_FRAMES-eng: 3264
      NUMBER_OF_BYTES-eng: 2506752
      SOURCE_ID-eng   : 0180BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-11 22:47:30
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:2(eng): Subtitle: dvd_subtitle, 720x576 (default)
    Metadata:
      BPS-eng         : 7748
      DURATION-eng    : 00:01:38.955022222
      NUMBER_OF_FRAMES-eng: 27
      NUMBER_OF_BYTES-eng: 95844
      SOURCE_ID-eng   : 0120BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-11 22:47:30
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:3(ger): Subtitle: dvd_subtitle, 720x576
    Metadata:
      BPS-eng         : 7564
      DURATION-eng    : 00:01:39.192533333
      NUMBER_OF_FRAMES-eng: 26
      NUMBER_OF_BYTES-eng: 93788
      SOURCE_ID-eng   : 0121BD
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.7 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2020-02-11 22:47:30
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
[12:16:46] scan: decoding previews for title 1
[12:16:46] scan: audio 0x1: ac3, rate=48000Hz, bitrate=192000 English (AC3) (2.0 ch) (192 kbps)
[12:16:46] scan: 10 previews, 720x576, 25.000 fps, autocrop = 4/30/8/4, aspect 4:3, PAR 16:15
[12:16:46] libhb: scan thread found 1 valid title(s)
[12:16:46] Starting Task: Encoding Pass
[12:16:46] Skipping crop/scale filter
[12:16:46] Auto Passthru: allowed codecs are AAC, AC3, E-AC3, TrueHD, DTS, DTS-HD, MP3, FLAC
[12:16:46] Auto Passthru: fallback is FLAC 16-bit
[12:16:46] Auto Passthru: using AC3 Passthru for track 1
[12:16:46] work: only 1 chapter, disabling chapter markers
[12:16:46] job configuration:
[12:16:46]  * source
[12:16:46]    + C:\!media\DVD\Jurassic Park\Jurassic Park III\Extras\A Visit to ILM\Muscle Simulation\Demonstration.mkv
[12:16:46]    + title 1, chapter(s) 1 to 1
[12:16:46]    + container: matroska,webm
[12:16:46]    + data rate: 4749 kbps
[12:16:46]  * destination
[12:16:46]    + C:\!media\DVD\Jurassic Park\Jurassic Park III\Extras\A Visit to ILM\Muscle Simulation\Demonstration_new.mkv
[12:16:46]    + container: Matroska (libavformat)
[12:16:46]  * video track
[12:16:46]    + decoder: mpeg2video
[12:16:46]    + filters
[12:16:46]      + Detelecine (pullup) ()
[12:16:46]      + Comb Detect (mode=3:spatial-metric=2:motion-thresh=1:spatial-thresh=1:filter-mode=2:block-thresh=40:block-width=16:block-height=16)
[12:16:46]      + Decomb (mode=39)
[12:16:46]      + Framerate Shaper (mode=0)
[12:16:46]        + frame rate: same as source (around 25.000 fps)
[12:16:46]    + Output geometry
[12:16:46]      + storage dimensions: 720 x 576
[12:16:46]      + pixel aspect ratio: 16 : 15
[12:16:46]      + display dimensions: 768 x 576
[12:16:46]    + encoder: H.264 (libx264)
[12:16:46]      + preset:  veryslow
[12:16:46]      + tune:    film
[12:16:46]      + profile: auto
[12:16:46]      + level:   auto
[12:16:46]      + quality: 21.00 (RF)
[12:16:46]      + color profile: 5-1-6
[12:16:46]  * subtitle track 1, English [VOBSUB] (track 0, id 0x2, Picture) -> Passthrough
[12:16:46]  * subtitle track 2, Deutsch [VOBSUB] (track 1, id 0x3, Picture) -> Passthrough
[12:16:46]  * audio track 1
[12:16:46]    + name: Stereo
[12:16:46]    + decoder: English (AC3) (2.0 ch) (192 kbps) (track 1, id 0x1)
[12:16:46]      + bitrate: 192 kbps, samplerate: 48000 Hz
[12:16:46]    + AC3 Passthru
[12:16:46] sync: expecting 2612 video frames
[12:16:46] encx264: encoding at constant RF 21.000000
[12:16:46] encx264: unparsed options: ref=16:bframes=8:b-adapt=2:direct=auto:deblock=-1,-1:analyse=all:me=umh:merange=24:subme=10:trellis=2:psy-rd=1,0.15:rc-lookahead=60
x264 [info]: using SAR=16/15
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High, level 4.0, 4:2:0, 8-bit
[12:16:46] sync: first pts video is 0
[12:16:46] sync: "Chapter 1" (1) at frame 1 time 0
[12:16:46] sync: first pts audio 0x1 is 0
[12:16:46] sync: first pts subtitle 0x2 is 162000
[12:16:46] sync: first pts subtitle 0x3 is 334800
[12:17:12] reader: done. 1 scr changes
[12:17:14] work: average encoding speed for job is 96.183609 fps
[12:17:15] comb detect: heavy 1571 | light 260 | uncombed 518 | total 2349
[12:17:15] decomb: deinterlaced 1571 | blended 260 | unfiltered 518 | total 2349
[12:17:15] vfr: lost time: 946800 (0 frames)
[12:17:15] vfr: gained time: 946800 (1044 frames) (0 not accounted for)
[12:17:15] ac3-decoder done: 3264 frames, 0 decoder errors
[12:17:15] mpeg2video-decoder done: 2612 frames, 0 decoder errors
[12:17:15] sync: got 2612 frames, 2612 expected
[12:17:15] sync: framerate min 25.000 fps, max 25.000 fps, avg 25.000 fps
x264 [info]: frame I:18    Avg QP:17.05  size: 43332
x264 [info]: frame P:522   Avg QP:20.53  size: 15694
x264 [info]: frame B:1809  Avg QP:25.14  size:  5852
x264 [info]: consecutive B-frames:  1.0%  3.4%  8.0% 29.6% 24.7% 25.8%  3.0%  1.4%  3.1%
x264 [info]: mb I  I16..4: 22.0% 63.3% 14.7%
x264 [info]: mb P  I16..4:  3.7% 14.4%  1.6%  P16..4: 34.8% 11.9% 11.5%  0.3%  0.1%    skip:21.7%
x264 [info]: mb B  I16..4:  0.6%  1.0%  0.2%  B16..8: 31.8%  6.6%  1.6%  direct: 6.7%  skip:51.4%  L0:45.5% L1:40.8% BI:13.6%
x264 [info]: 8x8 transform intra:68.1% inter:70.0%
x264 [info]: direct mvs  spatial:98.8% temporal:1.2%
x264 [info]: coded y,uvDC,uvAC intra: 67.1% 62.6% 34.3% inter: 20.2% 16.1% 2.2%
x264 [info]: i16 v,h,dc,p: 28% 59%  7%  6%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 10% 16%  8% 10% 11% 10% 11% 12%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:  9% 14%  6%  8% 12% 12% 13% 11% 15%
x264 [info]: i8c dc,h,v,p: 31% 40% 18% 11%
x264 [info]: Weighted P-Frames: Y:5.2% UV:3.8%
x264 [info]: ref P L0: 45.1%  9.1% 15.8%  5.7%  4.8%  3.9%  3.4%  1.8%  1.7%  1.6%  1.4%  1.3%  1.2%  1.2%  1.2%  0.8%
x264 [info]: ref B L0: 73.8% 11.0%  5.0%  2.1%  1.6%  1.4%  1.1%  0.7%  0.6%  0.6%  0.5%  0.5%  0.5%  0.4%  0.2%
x264 [info]: ref B L1: 95.2%  4.8%
x264 [info]: kb/s:1497.65
[12:17:15] mux: track 0, 2349 frames, 19558612 bytes, 1497.02 kbps, fifo 2048
[12:17:15] mux: track 1, 3264 frames, 2506752 bytes, 191.87 kbps, fifo 2048
[12:17:15] mux: track 2, 27 frames, 95844 bytes, 7.34 kbps, fifo 32
[12:17:15] mux: track 3, 26 frames, 93788 bytes, 7.18 kbps, fifo 32
[12:17:15] Finished work at: Wed Feb 12 12:17:15 2020
[12:17:15] libhb: work result = 0

# Encode Completed ...
rollin_eng
Veteran User
Posts: 4854
Joined: Wed May 04, 2011 11:06 pm

Re: Auto cropping crops too much

Post by rollin_eng »

You can increase the number of samples in the preferences.
Woodstock
Veteran User
Posts: 4619
Joined: Tue Aug 27, 2013 6:39 am

Re: Auto cropping crops too much

Post by Woodstock »

Anything that is automatic can be fooled. A car with "lane following" can be fooled into driving right into a concrete barrier when a lane splits, by trying to keep you in the center of the expanding lane, and an algorithm to look for black bars for cropping can be fooled by films that change aspect ratios at various points.
Silent_Strider
Enlightened
Posts: 102
Joined: Tue Dec 17, 2019 9:31 pm

Re: Auto cropping crops too much

Post by Silent_Strider »

rollin_eng wrote: Wed Feb 12, 2020 9:09 pm You can increase the number of samples in the preferences.
It is set to 60. As mentioned already. For all my videos. And the activity log will always tell 10. It still crops 30 pixels from the bottom away.
Woodstock wrote: Wed Feb 12, 2020 9:19 pm and an algorithm to look for black bars for cropping can be fooled by films that change aspect ratios at various points.
only that this video does not change any aspect ratio. At least I wouldn't know how to see that it changes.
mduell
Veteran User
Posts: 8197
Joined: Sat Apr 21, 2007 8:54 pm

Re: Auto cropping crops too much

Post by mduell »

Silent_Strider wrote: Wed Feb 12, 2020 8:54 pmTrying to find an average crop is.... bad in my opinion. I'd love to see an option, where you can switch between various crop algorithms.
E.g. one which really only crops digital back, another one going for a treshold and so on.
I look forward to your proposed patch on github.
Silent_Strider wrote:only that this video does not change any aspect ratio. At least I wouldn't know how to see that it changes.
Silent_Strider wrote: Wed Feb 12, 2020 8:54 pmIn this 20 frames, frames 3, 6, 19 and 20 definitely do not have a black border to the bottom.
Various other frames have digital black border
Various other frames have noisy black background
What you've described here is exactly changing aspect ratio.
Deleted User 11865

Re: Auto cropping crops too much

Post by Deleted User 11865 »

HandBrake always scans only 10 previews in the pre-encode scan. But during a full scan, it will honor the extra previews as set in settings, and they will affect autocrop accuracy.
Deleted User 11865

Re: Auto cropping crops too much

Post by Deleted User 11865 »

Silent_Strider wrote: Wed Feb 12, 2020 8:54 pm Description of problem or question:
Upon encoding some DVD extras from Jurassic Park, HB (again) crops the hell out of some videos and I don't see the reason why.

Here is an image of 20 frames throughout the movie.
https://i.imgur.com/jkMDLDx.jpg
This type of content cannot work reliably with autocrop, you'll have to set crop values manually.
Woodstock
Veteran User
Posts: 4619
Joined: Tue Aug 27, 2013 6:39 am

Re: Auto cropping crops too much

Post by Woodstock »

For these extras, manual cropping with zero values is the only appropriate crop, because they keep jumping back and forth between the rendered movie and "other footage". The movie itself is rendered at a consistent aspect ratio, so automatic cropping would work, but extras are, well, extras, and the studios usually don't spend that much time working on consistency.
Silent_Strider
Enlightened
Posts: 102
Joined: Tue Dec 17, 2019 9:31 pm

Re: Auto cropping crops too much

Post by Silent_Strider »

I made a few more examples from the Star Trek Voyager DVD Collection.

https://imgur.com/a/ubrLEMG

Handbrake wants to crop from 20 to 70 pixels from top _and_ bottom from each movie, even so there are clearly full screen sequences within them.

Wouldn't a crop only be useful if it really only looks for #0000 black borders? And as soon as it finds one, it keeps the maximum value instead of looking for lower ones? Instead of just loading all extra movies into Handbrake it took me a while longer to manually set up borders for many of the video files.

Besides, it's doing that for some full time movies for me as well. Examples are The Dark Knight and The Dark Knight Rises, where certain action sequences are in full screen, while the rest of the movie has black borders. I was really glad I noticed that before I converted the ripped BluRays. So it's not only extras with that problem.
Silent_Strider
Enlightened
Posts: 102
Joined: Tue Dec 17, 2019 9:31 pm

Re: Auto cropping crops too much

Post by Silent_Strider »

Of course I meant #000000 (eg. black) borders.
rollin_eng
Veteran User
Posts: 4854
Joined: Wed May 04, 2011 11:06 pm

Re: Auto cropping crops too much

Post by rollin_eng »

Rodeo's post above still stands.
Post Reply