Run H.265 on Intel QSV from CLI

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
Moses4sho
Posts: 1
Joined: Tue Dec 26, 2017 2:59 am

Run H.265 on Intel QSV from CLI

Post by Moses4sho »

Description of problem or question
Have regular recordings I encode with the H.265 (Intel QSV) codec.
Looking to automate a process that I regularly repeat, I downloaded the CLI, but using "-e x265" as one of the options doesn't seem to reproduce the same quality as I get using the GUI.
I assume this is because it's not using the same codec (I can somewhat test/replicate theory this using the GUI and log)

Ideally, I'd like the CLI that replicates my settings. I use the "Super HQ 1080p30 surround" preset, then change the codec to H.265 (Intel QSV) and set the encoder preset to "Quality". That's it. A few small tweeks off the preset, but I can't seem the documentation that calls the right codec and video optimization

Thank you in advance for your help!

HandBrake version (e.g., 1.0.0)
1.0.7 (GUI and CLI)


Operating system and version:
Windows 10

HandBrake Activity Log ***required*** (see How-to get an activity log)
[17:18:13] * video track
[17:18:13] + decoder: h264_qsv
[17:18:13] + bitrate 200 kbps
[17:18:13] mask erode thread started for segment 4
[17:18:13] + filters
[17:18:13] mask erode thread started for segment 6
[17:18:13] + 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)
[17:18:13] mask erode thread started for segment 7
[17:18:13] + Decomb (mode=39)
[17:18:13] + Framerate Shaper (mode=1)
[17:18:13] + frame rate: 59.940 fps -> constant 59.940 fps
[17:18:13] mask erode thread started for segment 5
[17:18:13] + Crop and Scale (width=1280:height=720:crop-top=0:crop-bottom=0:crop-left=0:crop-right=0)
[17:18:13] + source: 1280 * 720, crop (0/0/0/0): 1280 * 720, scale: 1280 * 720
[17:18:13] + Output geometry
[17:18:13] mask dilate thread started for segment 0
[17:18:13] + storage dimensions: 1280 x 720
[17:18:13] + pixel aspect ratio: 1 : 1
[17:18:13] + display dimensions: 1280 x 720
[17:18:13] + encoder: H.265 (Intel Media SDK)
[17:18:13] mask filter thread started for segment 2
[17:18:13] + preset: quality
[17:18:13] + profile: auto
[17:18:13] + level: auto
[17:18:13] + quality: 24.00 (QP)
[17:18:13] * audio track 1
[17:18:13] + decoder: English (AC3) (5.1 ch) (track 1, id 0x101)
[17:18:13] + bitrate: 384 kbps, samplerate: 48000 Hz
[17:18:13] + mixdown: Dolby Pro Logic II
[17:18:13] mask dilate thread started for segment 2
[17:18:13] + encoder: AAC (libavcodec)
[17:18:13] + bitrate: 160 kbps, samplerate: 48000 Hz
[17:18:13] * audio track 2
[17:18:13] + decoder: English (AC3) (5.1 ch) (track 1, id 0x101)
[17:18:13] mask dilate thread started for segment 3
[17:18:13] + bitrate: 384 kbps, samplerate: 48000 Hz
[17:18:13] + AC3 Passthru
Use any pastebin website and provide the URL it generates
- or -

Code: Select all

Paste log text between these markers.
[code][/i]
Deleted User 11865

Re: Run H.265 on Intel QSV from CLI

Post by Deleted User 11865 »

So the above log if from the GUI, correct?
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Run H.265 on Intel QSV from CLI

Post by BradleyS »

Using the nightly build, save a new preset in the GUI and then call it from the CLI with --preset-import-gui --preset=“My Preset Name”.
User avatar
s55
HandBrake Team
Posts: 10350
Joined: Sun Dec 24, 2006 1:05 pm

Re: Run H.265 on Intel QSV from CLI

Post by s55 »

Windows UI doesn’t use libhb presets. So you’d have to export a file and import that. Import gui won’t do anything
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Run H.265 on Intel QSV from CLI

Post by BradleyS »

Ah, right.
gmb
Bright Spark User
Posts: 350
Joined: Thu Mar 28, 2013 12:49 pm

Re: Run H.265 on Intel QSV from CLI

Post by gmb »

Lol Handbrake still doesn't support the superior ICQ for H265 after years, only CQP. And mbbrc doesn't work either.
User avatar
BradleyS
Moderator
Posts: 1860
Joined: Thu Aug 09, 2007 12:16 pm

Re: Run H.265 on Intel QSV from CLI

Post by BradleyS »

“still”

HandBrake is open source. Patches welcome.
Deleted User 11865

Re: Run H.265 on Intel QSV from CLI

Post by Deleted User 11865 »

gmb wrote: Sat Dec 30, 2017 6:27 pm Lol Handbrake still doesn't support the superior ICQ for H265 after years, only CQP. And mbbrc doesn't work either.
We query the encoder for its availability. If ICQ is not presented but is actually available, then the encoder is lying about its capabilities.
WhatZit
Experienced
Posts: 77
Joined: Sat Feb 13, 2016 2:45 am

Re: Run H.265 on Intel QSV from CLI

Post by WhatZit »

gmb wrote: Sat Dec 30, 2017 6:27 pmLol Handbrake still doesn't support the superior ICQ for H265 after years, only CQP. And mbbrc doesn't work either.
I don't know of a single open source project that synchronises with the MASTER on a timely basis.

Many are YEARS behind, with it not being uncommon to see 2013-vintage sources. Even the mighty QSVEnc is 7 months behind the times.

Given that the MFX upstream used in HB is a FORK of a FORK, the allegedly-intelligent HEVC rate control feature you report missing is bound to be a result of desynchronisation.
Moses4sho wrote: Tue Dec 26, 2017 3:16 amHave regular recordings I encode with the H.265 (Intel QSV) codec.
I downloaded the CLI, but using "-e x265" as one of the options doesn't seem to reproduce the same quality as I get using the GUI.
Shouldn't you be using "--encoder qsv_h265 --encoder-preset quality" if you want QuickSync?

Something I should point out is that HandBrakeCLI modifies its help text to only display workable options, especially pertaining to QSV hardware. So, if you never saw "qsv_h265" in the list of encoders, then there's something wrong with your system, probably drivers.

Code: Select all

hb_encoder_internal_t hb_video_encoders[]  =
{
    // legacy encoders, back to HB 0.9.4 whenever possible (disabled)
    { { "FFmpeg",              "ffmpeg",     NULL,                      HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_MPEG4,  },
    { { "MPEG-4 (FFmpeg)",     "ffmpeg4",    NULL,                      HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_MPEG4,  },
    { { "MPEG-2 (FFmpeg)",     "ffmpeg2",    NULL,                      HB_VCODEC_FFMPEG_MPEG2, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_MPEG2,  },
    { { "VP3 (Theora)",        "libtheora",  NULL,                      HB_VCODEC_THEORA,                       HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_THEORA, },
    // actual encoders
    { { "H.264 (x264)",        "x264",       "H.264 (libx264)",         HB_VCODEC_X264_8BIT,         HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H264,   },
    { { "H.264 10-bit (x264)", "x264_10bit", "H.264 10-bit (libx264)",  HB_VCODEC_X264_10BIT,   HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H264,   },
    { { "H.264 (Intel QSV)",   "qsv_h264",   "H.264 (Intel Media SDK)", HB_VCODEC_QSV_H264,     HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H264,   },
    { { "H.265 (x265)",        "x265",       "H.265 (libx265)",         HB_VCODEC_X265_8BIT,      HB_MUX_AV_MP4|HB_MUX_AV_MKV,   }, NULL, 1, HB_GID_VCODEC_H265,   },
    { { "H.265 10-bit (x265)", "x265_10bit", "H.265 10-bit (libx265)",  HB_VCODEC_X265_10BIT,     HB_MUX_AV_MP4|HB_MUX_AV_MKV,   }, NULL, 1, HB_GID_VCODEC_H265,   },
    { { "H.265 12-bit (x265)", "x265_12bit", "H.265 12-bit (libx265)",  HB_VCODEC_X265_12BIT,     HB_MUX_AV_MP4|HB_MUX_AV_MKV,   }, NULL, 1, HB_GID_VCODEC_H265,   },
    { { "H.265 16-bit (x265)", "x265_16bit", "H.265 16-bit (libx265)",  HB_VCODEC_X265_16BIT,     HB_MUX_AV_MP4|HB_MUX_AV_MKV,   }, NULL, 1, HB_GID_VCODEC_H265,   },
    { { "H.265 (Intel QSV)",   "qsv_h265",   "H.265 (Intel Media SDK)", HB_VCODEC_QSV_H265,     HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H265,   },
    { { "H.265 10-bit (Intel QSV)",   "qsv_h265_10bit",   "H.265 10-bit (Intel Media SDK)", HB_VCODEC_QSV_H265_10BIT,     HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H265,   },
    { { "MPEG-4",              "mpeg4",      "MPEG-4 (libavcodec)",     HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_MPEG4,  },
    { { "MPEG-2",              "mpeg2",      "MPEG-2 (libavcodec)",     HB_VCODEC_FFMPEG_MPEG2, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_MPEG2,  },
    { { "VP8",                 "VP8",        "VP8 (libvpx)",            HB_VCODEC_FFMPEG_VP8,                   HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_VP8,    },
    { { "VP9",                 "VP9",        "VP9 (libvpx)",            HB_VCODEC_FFMPEG_VP9,                   HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_VP9,    },
    { { "Theora",              "theora",     "Theora (libtheora)",      HB_VCODEC_THEORA,                       HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_THEORA, },
};
gmb
Bright Spark User
Posts: 350
Joined: Thu Mar 28, 2013 12:49 pm

Re: Run H.265 on Intel QSV from CLI

Post by gmb »

ICQ.png
ICQ.png (34.56 KiB) Viewed 1300 times
Rodeo wrote: Sat Dec 30, 2017 7:02 pm
gmb wrote: Sat Dec 30, 2017 6:27 pm Lol Handbrake still doesn't support the superior ICQ for H265 after years, only CQP. And mbbrc doesn't work either.
We query the encoder for its availability. If ICQ is not presented but is actually available, then the encoder is lying about its capabilities.

Then it should work if it's working properly.

http://fs1.directupload.net/images/180101/mesodxp5.png
WhatZit wrote: Sun Dec 31, 2017 1:42 am Even the mighty QSVEnc is 7 months behind the times.

QSVENC isn't behind, it supports Intels newest Media SDK on Windows which came out in June 2017. You could say Intels Windows media sdk team is behind but it isn't the fault of QSVEnc. ICQ is supported from the beginning of Intels H265 start with Skylake 2.5 years ago, if there is H265 support you would expect that ICQ is working beside CQP.
Deleted User 11865

Re: Run H.265 on Intel QSV from CLI

Post by Deleted User 11865 »

Interesting. Just as a reference, which software is the above output from, and on which GPU/hardware?
WhatZit
Experienced
Posts: 77
Joined: Sat Feb 13, 2016 2:45 am

Re: Run H.265 on Intel QSV from CLI

Post by WhatZit »

Rodeo wrote: Mon Jan 01, 2018 2:48 amInteresting. Just as a reference, which software is the above output from, and on which GPU/hardware?
Looks like QSVEncC's --check-features to me. Just tested it myself on an old i3-6100 HTPC, and ICQ comes up as a HEVC feature.
gmb wrote: Mon Jan 01, 2018 1:52 amICQ is supported from the beginning of Intels H265 start with Skylake 2.5 years ago, if there is H265 support you would expect that ICQ is working beside CQP.
You're correct. Both HEVC and ICQ support were simultaneously added in SDK 2014 (refer 1.6.1 in this PDF): https://jp.xlsoft.com/documents/intel/m ... uide_0.pdf

I still believe that it is desyncing from Intel's MFX dispatch master that's responsible for the missing functionality.
Deleted User 11865

Re: Run H.265 on Intel QSV from CLI

Post by Deleted User 11865 »

WhatZit wrote: Mon Jan 01, 2018 12:39 pmI still believe that it is desyncing from Intel's MFX dispatch master that's responsible for the missing functionality.
You never know, but I highly doubt it.
Deleted User 11865

Re: Run H.265 on Intel QSV from CLI

Post by Deleted User 11865 »

WhatZit wrote: Mon Jan 01, 2018 12:39 pmI still believe that it is desyncing from Intel's MFX dispatch master that's responsible for the missing functionality.
As expected, it wasn't. A one-line fix (to HandBrake code) will make its way to the nightly builds in the coming days.
gmb
Bright Spark User
Posts: 350
Joined: Thu Mar 28, 2013 12:49 pm

Re: Run H.265 on Intel QSV from CLI

Post by gmb »

WhatZit wrote: Mon Jan 01, 2018 12:39 pm
Rodeo wrote: Mon Jan 01, 2018 2:48 amInteresting. Just as a reference, which software is the above output from, and on which GPU/hardware?
Looks like QSVEncC's --check-features to me.

Yes it is. But there is one detection error in it for whatever reason. B-Pyramid isn't supported for HEVC encoding in QSVEnc, unlike Handbrake. This must be a QSVEnc limitation rather than Intels limitation.

Rodeo wrote: Wed Jan 03, 2018 10:41 pm
WhatZit wrote: Mon Jan 01, 2018 12:39 pmI still believe that it is desyncing from Intel's MFX dispatch master that's responsible for the missing functionality.
As expected, it wasn't. A one-line fix (to HandBrake code) will make its way to the nightly builds in the coming days.

Ok I will check if it works. What about mbbrc? This is the last major function missing for HEVC at the moment. This rate control method should work, as ICQ it is supported since Intels HEVC introduction in 2015. The other missing stuff is minor, it doesn't help really.
Deleted User 11865

Re: Run H.265 on Intel QSV from CLI

Post by Deleted User 11865 »

I never got the HEVC encoder to accept an attached mfxExtCodingOption2 (which is used to set/unset MBBRC). Yet the current code detects the same structure as working fine for the H.264 encoder. I guess I need to adjust some code because the HEVC encoder again responds differently to the MFXVideoENCODE_Query call, compared to its H.264 counterpart.
gmb
Bright Spark User
Posts: 350
Joined: Thu Mar 28, 2013 12:49 pm

Re: Run H.265 on Intel QSV from CLI

Post by gmb »

MBBRC seems to be enabled by default anyway. Quicksync decoding doesn't work by the way, my CPU load is fully loaded.
Deleted User 11865

Re: Run H.265 on Intel QSV from CLI

Post by Deleted User 11865 »

Well, that's a know issue (accelerated decoding still works, but the zerocopy path and hardware-accelerated filtering aren't used, hence the high CPU usage). This is obviously meant to be fixed, but it's a matter of (lack of) time, really.
WhatZit
Experienced
Posts: 77
Joined: Sat Feb 13, 2016 2:45 am

Re: Run H.265 on Intel QSV from CLI

Post by WhatZit »

Rodeo wrote: Sat Jan 06, 2018 6:38 pmI never got the HEVC encoder to accept an attached mfxExtCodingOption2 (which is used to set/unset MBBRC). Yet the current code detects the same structure as working fine for the H.264 encoder.
There aren't many specific divergences between 264 & 265 in the function of QSV structure fields, but a big one is mfxInfoMFX.IdrInterval, which your code explicitly sets to 0:

Code: Select all

param->videoParam->mfx.IdrInterval  = 0; // all I-frames are IDR
For h.264, 0 formats every I-frame as an IDR-frame
For h.265, 0 formats only the 1st I-frame as an IDR-frame (a value of 1 formats every I-frame)

Yeah, what were they thinking?
Post Reply