Handbrake: HandbrakeCLI cropping height when encoding vertical video

Created on 4 Jun 2020  路  3Comments  路  Source: HandBrake/HandBrake

Problem description:

I run the following command to encode a vertical MP4 video (720x1280) and the resulting output video has cropped height (720x1190):

搂 /Applications/HandBrakeCLI -i video.mp4 -o output_video.mp4 -e x264 -b 240 -q 30 -r 24 -E mp3 -B 96

Interestingly, this does not happen with horizontal videos (!).
Is there a way to control the video cropping in HandbrakeCLI?

HandBrake version

1.3.1

Operating system and version:

MacOS Catalina 10.15.4 (19E287)

HandBrake Activity Log:

~~~
[06:44:33] Compile-time hardening features are enabled
[06:44:33] hb_init: starting libhb thread
[06:44:33] thread 700009ee9000 started ("libhb")
HandBrake 1.3.1 (2020010400) - Darwin x86_64 - https://handbrake.fr
4 CPUs detected
Opening video.mp4...
[06:44:33] CPU: Intel(R) Core(TM) i5-6360U CPU @ 2.00GHz
[06:44:33] - Intel microarchitecture Skylake
[06:44:33] - logical processor count: 4
[06:44:33] hb_scan: path=video.mp4, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:323: failed opening UDF image video.mp4
disc.c:424: error opening file BDMV/index.bdmv
disc.c:424: error opening file BDMV/BACKUP/index.bdmv
bluray.c:2585: nav_get_title_list(video.mp4/) failed
[06:44:33] 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
[06:44:33] dvd: not a dvd - trying as a stream/file instead
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2020-06-03T17:06:44.000000Z
com.android.version: 9
Duration: 00:00:21.30, start: 0.000000, bitrate: 9075 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, unknown/bt470bg/unknown), 1280x720, 8795 kb/s, SAR 1:1 DAR 16:9, 19.95 fps, 20.05 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 270
creation_time : 2020-06-03T17:06:44.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of 90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
Metadata:
creation_time : 2020-06-03T17:06:44.000000Z
handler_name : SoundHandle
[06:44:33] scan: decoding previews for title 1
[06:44:33] scan: audio 0x1: aac, rate=48000Hz, bitrate=128035 English (AAC LC) (1.0 ch) (128 kbps)
Scanning title 1 of 1, preview 1, 10.00 %[06:44:33] scan: 10 previews, 720x1280, 19.950 fps, autocrop = 0/90/0/0, aspect 1:1.78, PAR 1:1
[06:44:33] libhb: scan thread found 1 valid title(s)

  • Using preset: CLI Default
  • title 1:

    • stream: video.mp4

    • duration: 00:00:21

    • size: 720x1280, pixel aspect: 1/1, display aspect: 0.56, 19.950 fps

    • autocrop: 0/90/0/0

    • chapters:

    • 1: duration 00:00:21

    • audio tracks:

    • 1, English (AAC LC) (1.0 ch) (128 kbps) (iso639-2: eng)

    • subtitle tracks:

      [06:44:33] Starting work at: Thu Jun 4 06:44:33 2020

[06:44:33] 1 job(s) to process
[06:44:33] json job:
{
"Audio": {
"AudioList": [
{
"Bitrate": 96,
"CompressionLevel": -1.0,
"DRC": 0.0,
"DitherMethod": "auto",
"Encoder": "mp3",
"Gain": 0.0,
"Mixdown": "mono",
"NormalizeMixLevel": false,
"PresetEncoder": "mp3",
"Quality": -3.0,
"Samplerate": 0,
"Track": 0
}
],
"CopyMask": [
"copy:aac",
"copy:ac3",
"copy:eac3",
"copy:dtshd",
"copy:dts",
"copy:mp3",
"copy:truehd",
"copy:flac"
],
"FallbackEncoder": "ca_aac"
},
"Destination": {
"AlignAVStart": false,
"ChapterList": [
{
"Duration": {
"Hours": 0,
"Minutes": 0,
"Seconds": 21,
"Ticks": 1917360
},
"Name": ""
}
],
"ChapterMarkers": false,
"File": "output_video.mp4",
"InlineParameterSets": false,
"Mp4Options": {
"IpodAtom": false,
"Mp4Optimize": false
},
"Mux": "m4v"
},
"Filters": {
"FilterList": [
{
"ID": 6,
"Settings": {
"mode": 2,
"rate": "27000000/1125000"
}
},
{
"ID": 12,
"Settings": {
"crop-bottom": 90,
"crop-left": 0,
"crop-right": 0,
"crop-top": 0,
"height": 1190,
"width": 720
}
}
]
},
"Metadata": {},
"PAR": {
"Den": 1,
"Num": 1
},
"SequenceID": 0,
"Source": {
"Angle": 0,
"Path": "video.mp4",
"Range": {
"End": 1,
"Start": 1,
"Type": "chapter"
},
"Title": 1
},
"Subtitle": {
"Search": {
"Burn": true,
"Default": false,
"Enable": false,
"Forced": false
},
"SubtitleList": []
},
"Video": {
"ColorFormat": 0,
"ColorMatrix": 1,
"ColorPrimaries": 5,
"ColorRange": 1,
"ColorTransfer": 1,
"Encoder": "x264",
"Level": "auto",
"Options": "",
"Preset": "medium",
"Profile": "auto",
"QSV": {
"AsyncDepth": 4,
"Decode": false
},
"Quality": 30.0,
"Tune": "",
"Turbo": false,
"TwoPass": false
}
}
[06:44:33] Starting Task: Encoding Pass
[06:44:34] work: compression level not specified, track 1 setting compression level 2.00
[06:44:34] job configuration:
[06:44:34] * source
[06:44:34] + video.mp4
[06:44:34] + title 1, chapter(s) 1 to 1
[06:44:34] + container: mov,mp4,m4a,3gp,3g2,mj2
[06:44:34] + data rate: 9075 kbps
[06:44:34] * destination
[06:44:34] + output_video.mp4
[06:44:34] + container: MPEG-4 (libavformat)
[06:44:34] * video track
[06:44:34] + decoder: h264
[06:44:34] + bitrate 8795 kbps
[06:44:34] + filters
[06:44:34] + Framerate Shaper (mode=2:rate=27000000/1125000)
[06:44:34] + frame rate: 19.950 fps -> peak rate limited to 24.000 fps
[06:44:34] + Crop and Scale (width=720:height=1190:crop-top=0:crop-bottom=90:crop-left=0:crop-right=0)
[06:44:34] + source: 720 * 1280, crop (0/90/0/0): 720 * 1190, scale: 720 * 1190
[06:44:34] + Output geometry
[06:44:34] + storage dimensions: 720 x 1190
[06:44:34] + pixel aspect ratio: 1 : 1
[06:44:34] + display dimensions: 720 x 1190
[06:44:34] + encoder: H.264 (libx264)
[06:44:34] + preset: medium
[06:44:34] + profile: auto
[06:44:34] + level: auto
[06:44:34] + quality: 30.00 (RF)
[06:44:34] + color profile: 5-1-1
[06:44:34] * audio track 1
[06:44:34] + decoder: English (AAC LC) (1.0 ch) (128 kbps) (track 1, id 0x1)
[06:44:34] + bitrate: 128 kbps, samplerate: 48000 Hz
[06:44:34] + mixdown: Mono
[06:44:34] + dither: triangular
[06:44:34] + encoder: MP3 (libmp3lame)
[06:44:34] + bitrate: 96 kbps, samplerate: 48000 Hz
[06:44:34] + compression level: 2.00
[06:44:34] sync: expecting 425 video frames
[06:44:34] encx264: min-keyint: 20, keyint: 200
[06:44:34] encx264: encoding at constant RF 30.000000
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High, level 3.1, 4:2:0, 8-bit
Encoding: task 1 of 1, 0.00 %[06:44:34] sync: first pts video is 0
[06:44:34] sync: Chapter 1 at frame 1 time 0
[06:44:34] sync: first pts audio 0x1 is 0
Encoding: task 1 of 1, 86.35 % (31.41 fps, avg 40.04 fps, ETA 00h00m01s)[06:44:43] reader: done. 1 scr changes
Encoding: task 1 of 1, 90.35 % (31.41 fps, avg 40.04 fps, ETA 00h00m01s)[06:44:45] work: average encoding speed for job is 40.036922 fps
[06:44:46] vfr: 425 frames output, 0 dropped and 0 duped for CFR/PFR
[06:44:46] vfr: lost time: 0 (0 frames)
[06:44:46] vfr: gained time: 0 (0 frames) (0 not accounted for)
[06:44:46] aac-decoder done: 996 frames, 0 decoder errors
[06:44:46] h264-decoder done: 425 frames, 0 decoder errors
[06:44:46] sync: got 425 frames, 425 expected
[06:44:46] sync: framerate min 9.428 fps, max 20.049 fps, avg 19.934 fps
x264 [info]: frame I:14 Avg QP:24.44 size: 8054
x264 [info]: frame P:123 Avg QP:27.27 size: 4082
x264 [info]: frame B:288 Avg QP:28.92 size: 1558
x264 [info]: consecutive B-frames: 9.2% 0.5% 2.8% 87.5%
x264 [info]: mb I I16..4: 28.7% 70.7% 0.6%
x264 [info]: mb P I16..4: 15.9% 20.9% 0.0% P16..4: 21.1% 1.4% 0.4% 0.0% 0.0% skip:40.2%
x264 [info]: mb B I16..4: 0.5% 0.4% 0.0% B16..8: 25.0% 0.6% 0.0% direct: 0.8% skip:72.7% L0:44.4% L1:54.9% BI: 0.6%
x264 [info]: 8x8 transform intra:59.6% inter:99.1%
x264 [info]: coded y,uvDC,uvAC intra: 11.6% 22.5% 0.8% inter: 2.7% 7.7% 0.0%
x264 [info]: i16 v,h,dc,p: 40% 30% 11% 19%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 11% 55% 2% 2% 2% 2% 2% 1%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 21% 26% 6% 6% 5% 5% 4% 2%
x264 [info]: i8c dc,h,v,p: 68% 16% 15% 1%
x264 [info]: Weighted P-Frames: Y:1.6% UV:1.6%
x264 [info]: ref P L0: 61.0% 10.5% 20.5% 8.0% 0.0%
x264 [info]: ref B L0: 90.5% 7.6% 1.9%
x264 [info]: ref B L1: 96.1% 3.9%
x264 [info]: kb/s:399.09
[06:44:46] mux: track 0, 425 frames, 1063100 bytes, 398.28 kbps, fifo 512
[06:44:46] mux: track 1, 886 frames, 255168 bytes, 95.60 kbps, fifo 1024
[06:44:46] Finished work at: Thu Jun 4 06:44:46 2020

Muxing: this may take awhile...[06:44:46] libhb: work result = 0

Encode done!

HandBrake has exited.
~~~

All 3 comments

--crop="0:0:0:0" will disable automatic cropping.

Thanks, @bradleysepos! This solves my problem. On another note, I would have imagined this is the default behaviour (not to crop) (!).

Encoding black bars is not efficient so not default.

There can be instances where auto-crop can get it wrong but it's reliable enough that it wouldn't justify a change in default behaviour. It's also easily configurable.

Was this page helpful?
0 / 5 - 0 ratings