Custom export preset to hevc_videotoolbox with constant-quality

What is your operating system?

macOS 12.3.1 (on Apple Silicon)

What is your Shotcut version (see Help > About Shotcut)? Is it 32-bit?

22.03.30 macOS aarch64

Can you repeat the problem? If so, what are the steps?

Firstly, yes, it (constant quality via videotoolbox) can be done, at least on Apple Silicon. Handbrake found out how, and for a while I’ve been exporting to utvideo as an intermediate and then using Handbrake, which of course means gigantic intermediate files, but it turns out it can be done in Shotcut, and Handbrake left a clue here, before they switched to riding the videotoolbox api directly for other reasons (this was working before they did that):

https://github.com/HandBrake/HandBrake/discussions/3882

ie: use the qscale=n option where n is the value you’d give to the constant-quality slider in HandBrake. (This is a 0-100 value; I typically use 50.) So I can select hevc_videotoolbox, select “Quality based VBR” but I have to ignore the Quality field in the UI and enter “qscale=50” in the Other tab.

And this works. I get the file I want in about the same time that Handbrake takes. (I understand it only works on Apple Silicon, not Intel with T2, but haven’t tested that myself.)

The problem starts when I try to make a preset of this. With “qscale=50” in the preset, I think that gets read in as a UI option, but the value is out of the range of expected values, so it’s probably being ignored. The preset loads with default Average Bitrate options, and the “qscale=50” is missing from the Other tab.

If I manually correct those again, it works.

I think the ideal fix would be for that Quality field, when you select “Quality-based VBR” in the codec tab, should be aware of the way it’s used for this codec. In this case, that the editable percentage value field just passes through its value verbatim to qscale, rather than going through the conversion it does now. And therefore to also accept that value as valid when reading it back from the preset.

A possibly cheaper fix might be, that if the qscale value read in seems out of range, assume someone knows what they’re doing (as it probably didn’t come out of the UI quality setting, someone had to type it in), and restore it back to the Other tab. But also to select “Quality-based VBR” in the codec tab, as a quality-based setting was specified, not a bitrate.

Example, what I get if I hit + to add a just-worked export setting to the presets:

vtag=hvc1
preset=medium
movflags=+faststart
qscale=50
f=mp4
acodec=aac_at
channels=2
ar=48000
ab=256k
vcodec=hevc_videotoolbox
g=250
bf=3
pix_fmt=nv12
width=1920
height=1080
aspect=1.77778
progressive=1
top_field_first=2
deinterlace_method=yadif
rescale=bilinear
frame_rate_num=50000000
frame_rate_den=1000000
threads=7

After editing to remove settings that I’d rather it took from the source or default each time, which is an ongoing exercise, but wrt the above, the same thing happens:

vtag=hvc1
preset=medium
movflags=+faststart
qscale=50
f=mp4
acodec=aac_at
ar=48000
ab=256k
vcodec=hevc_videotoolbox
progressive=1
threads=7
meta.preset.extension=mp4

Thank you for your excellent bug report. This is fixed for the next version.

1 Like