Skip to content

H.265 QSV encoding fails with Intel Media SDK 20.1.1 #2858

Closed

Description

@yuichiro-naito

Problem description:

When I choose H.265 QSV encoding, HandBrake fails encoding soon and no output was made. H.264 QSV works for me.
I found following error message in Activity log.

[12:26:04] qsv_hevc_make_header: MFXVideoENCODE_EncodeFrameAsync failed (-5)

According to mfxdefs.h, -5 is MFX_ERR_NOT_ENOUGH_BUFFER.
It seems that Intel Media SDK requires more buffer memory.

I think increasing buffer memory will solv this problem.
Following patch works for me.

yuichiro-naito@e468a37

Intel Media SDK Release note says that HEVC encode has been refactored.
I'm guessing that refactor affects memory requirement.

https://github.com/Intel-Media-SDK/MediaSDK/releases/tag/intel-mediasdk-20.1.0
Intel-Media-SDK/MediaSDK@b7dad9d

HandBrake version (e.g., 1.3.0):

HandBrake master branch rev 434b24b.

Operating system and version (e.g., Ubuntu 19.10, macOS 10.15 Catalina, Windows 10 1909):

FreeBSD CURRENT r360999

QSV related library versions:

  • intel-media-sdk-20.1.1
  • libva-2.7.1
  • libva-intel-media-driver-20.1.1
  • libva-utils-2.7.1

Error message text and/or screenshot:

screen

HandBrake Activity Log:

[12:25:40] gtkgui: HandBrake 20200514184224-434b24bcf-master (2020051501) - FreeBSD x86_64 - https://handbrake.fr
[12:25:40] hb_display_init: attempting VA driver 'iHD'
libva info: VA-API version 1.7.0
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva info: va_openDriver() returns 0
[12:25:40] hb_init: starting libhb thread
[12:25:40] hb_init: starting libhb thread
[12:25:40] hb_init: starting libhb thread
[12:25:53] CPU: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
[12:25:53] - Intel microarchitecture Skylake
[12:25:53] - logical processor count: 8
[12:25:53] Intel Quick Sync Video support: yes
[12:25:53] - Intel Media SDK hardware: API 1.32 (minimum: 1.3)
[12:25:53] - H.264 encoder: yes
[12:25:53] - preferred implementation: hardware (any) via ANY
[12:25:53] - capabilities (hardware): breftype icq+la+i+downs vsinfo opt1 opt2+mbbrc+extbrc+trellis+ib_adapt+nmpslice
[12:25:53] - H.265 encoder: yes (8bit: yes, 10bit: no)
[12:25:53] - preferred implementation: hardware (any) via ANY
[12:25:53] - capabilities (hardware): bpyramid icq vsinfo opt1
[12:25:53] hb_scan: path=/zpool/video/test/CIMG0145.AVI, title_index=0
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:323: failed opening UDF image /zpool/video/test/CIMG0145.AVI
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(/zpool/video/test/CIMG0145.AVI/) failed
[12:25:53] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.1
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:25:53] dvd: not a dvd - trying as a stream/file instead
Input #0, avi, from '/zpool/video/test/CIMG0145.AVI':
Metadata:
creation_time : 2005-10-28/ 14:20
encoder : CASIO EX-S600
Duration: 00:00:18.02, start: 0.000000, bitrate: 3966 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (M4S2 / 0x3253344D), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 3783 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 30k tbc
Stream #0:1: Audio: adpcm_ima_wav ([17][0][0][0] / 0x0011), 44100 Hz, 1 channels, s16p, 176 kb/s
[12:25:53] scan: decoding previews for title 1
[12:25:53] scan: audio 0x1: adpcm_ima_wav, rate=44100Hz, bitrate=176400 Unknown (adpcm_ima_wav) (1.0 ch) (176 kbps)
[12:25:53] scan: 10 previews, 640x480, 29.970 fps, autocrop = 0/0/0/0, aspect 4:3, PAR 1:1
[12:25:53] libhb: scan thread found 1 valid title(s)

(ghb:90278): Gtk-WARNING **: 12:26:03.890: Calling org.xfce.Session.Manager.Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: 'Inhibit' ?????????????
[12:26:03] gtkgui: Modified Preset: /General/Fast 1080p30
[12:26:03] Starting work at: Fri May 15 12:26:03 2020

[12:26:03] 1 job(s) to process
[12:26:03] json job:
{
"Audio": {
"AudioList": [
{
"Bitrate": 160,
"CompressionLevel": -1.0,
"DRC": 0.0,
"DitherMethod": "auto",
"Encoder": "fdk_aac",
"Gain": 0.0,
"Mixdown": "mono",
"NormalizeMixLevel": false,
"PresetEncoder": "fdk_aac",
"Quality": -3.0,
"Samplerate": 0,
"Track": 0
}
],
"CopyMask": [
"copy:aac"
],
"FallbackEncoder": "fdk_aac"
},
"Destination": {
"AlignAVStart": true,
"ChapterList": [
{
"Duration": {
"Hours": 0,
"Minutes": 0,
"Seconds": 18,
"Ticks": 1621636
},
"Name": ""
}
],
"ChapterMarkers": false,
"File": "/usr/home/yuichiro/CIMG0145.m4v",
"InlineParameterSets": false,
"Mp4Options": {
"IpodAtom": false,
"Mp4Optimize": false
},
"Mux": "m4v"
},
"Filters": {
"FilterList": [
{
"ID": 3,
"Settings": {
"block-height": "16",
"block-thresh": "40",
"block-width": "16",
"filter-mode": "2",
"mode": "3",
"motion-thresh": "1",
"spatial-metric": "2",
"spatial-thresh": "1"
}
},
{
"ID": 4,
"Settings": {
"mode": "7"
}
},
{
"ID": 6,
"Settings": {
"mode": 2,
"rate": "27000000/900000"
}
},
{
"ID": 12,
"Settings": {
"crop-bottom": 0,
"crop-left": 0,
"crop-right": 0,
"crop-top": 0,
"height": 480,
"width": 640
}
}
]
},
"Metadata": {
"Name": "CIMG0145"
},
"PAR": {
"Den": 1,
"Num": 1
},
"SequenceID": 0,
"Source": {
"Angle": 0,
"Path": "/zpool/video/test/CIMG0145.AVI",
"Range": {
"End": 1,
"Start": 1,
"Type": "chapter"
},
"Title": 1
},
"Subtitle": {
"Search": {
"Burn": true,
"Default": false,
"Enable": false,
"Forced": false
},
"SubtitleList": []
},
"Video": {
"ColorFormat": 0,
"ColorMatrix": 6,
"ColorPrimaries": 6,
"ColorRange": 0,
"ColorTransfer": 1,
"Encoder": "qsv_h265",
"Level": "auto",
"Options": "",
"Preset": "balanced",
"Profile": "auto",
"QSV": {
"AsyncDepth": 4,
"Decode": false
},
"Quality": 16.0,
"Tune": "",
"Turbo": false,
"TwoPass": false
}
}
[12:26:03] CPU: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
[12:26:03] - Intel microarchitecture Skylake
[12:26:03] - logical processor count: 8
[12:26:03] Intel Quick Sync Video support: yes
[12:26:03] - Intel Media SDK hardware: API 1.32 (minimum: 1.3)
[12:26:03] - H.264 encoder: yes
[12:26:03] - preferred implementation: hardware (any) via ANY
[12:26:03] - capabilities (hardware): breftype icq+la+i+downs vsinfo opt1 opt2+mbbrc+extbrc+trellis+ib_adapt+nmpslice
[12:26:03] - H.265 encoder: yes (8bit: yes, 10bit: no)
[12:26:03] - preferred implementation: hardware (any) via ANY
[12:26:03] - capabilities (hardware): bpyramid icq vsinfo opt1
[12:26:03] hb_scan: path=/zpool/video/test/CIMG0145.AVI, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:323: failed opening UDF image /zpool/video/test/CIMG0145.AVI
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(/zpool/video/test/CIMG0145.AVI/) failed
[12:26:03] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.1
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:26:03] dvd: not a dvd - trying as a stream/file instead
Input #0, avi, from '/zpool/video/test/CIMG0145.AVI':
Metadata:
creation_time : 2005-10-28/ 14:20
encoder : CASIO EX-S600
Duration: 00:00:18.02, start: 0.000000, bitrate: 3966 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (M4S2 / 0x3253344D), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 3783 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 30k tbc
Stream #0:1: Audio: adpcm_ima_wav ([17][0][0][0] / 0x0011), 44100 Hz, 1 channels, s16p, 176 kb/s
[12:26:03] scan: decoding previews for title 1
[12:26:03] scan: audio 0x1: adpcm_ima_wav, rate=44100Hz, bitrate=176400 Unknown (adpcm_ima_wav) (1.0 ch) (176 kbps)
[12:26:03] scan: 10 previews, 640x480, 29.970 fps, autocrop = 0/0/0/0, aspect 4:3, PAR 1:1
[12:26:03] libhb: scan thread found 1 valid title(s)
[12:26:03] Starting Task: Encoding Pass
[12:26:03] Skipping crop/scale filter
[12:26:04] job configuration:
[12:26:04] * source
[12:26:04] + /zpool/video/test/CIMG0145.AVI
[12:26:04] + title 1, chapter(s) 1 to 1
[12:26:04] + container: avi
[12:26:04] + data rate: 3966 kbps
[12:26:04] * destination
[12:26:04] + /usr/home/yuichiro/CIMG0145.m4v
[12:26:04] + container: MPEG-4 (libavformat)
[12:26:04] + align initial A/V stream timestamps
[12:26:04] * video track
[12:26:04] + decoder: mpeg4
[12:26:04] + bitrate 3783 kbps
[12:26:04] + filters
[12:26:04] + 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:26:04] + Decomb (mode=39)
[12:26:04] + Framerate Shaper (mode=2:rate=27000000/900000)
[12:26:04] + frame rate: 29.970 fps -> peak rate limited to 30.000 fps
[12:26:04] + Output geometry
[12:26:04] + storage dimensions: 640 x 480
[12:26:04] + pixel aspect ratio: 1 : 1
[12:26:04] + display dimensions: 640 x 480
[12:26:04] + encoder: H.265 (Intel Media SDK)
[12:26:04] + preset: balanced
[12:26:04] + profile: auto
[12:26:04] + level: auto
[12:26:04] + quality: 16.00 (ICQ)
[12:26:04] + color profile: 6-1-6
[12:26:04] * audio track 1
[12:26:04] + decoder: Unknown (adpcm_ima_wav) (1.0 ch) (176 kbps) (track 1, id 0x1)
[12:26:04] + bitrate: 176 kbps, samplerate: 44100 Hz
[12:26:04] + mixdown: Mono
[12:26:04] + dither: triangular
[12:26:04] + encoder: AAC (libfdk_aac)
[12:26:04] + bitrate: 160 kbps, samplerate: 44100 Hz
[12:26:04] sync: expecting 540 video frames
[12:26:04] hb_display_init: using VA driver 'iHD'
libva info: VA-API version 1.7.0
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva info: va_openDriver() returns 0
[12:26:04] qsv_hevc_make_header: MFXVideoENCODE_EncodeFrameAsync failed (-5)
[12:26:04] encqsvInit: qsv_hevc_make_header failed
[12:26:04] Failure to initialise thread 'Quick Sync Video encoder (Intel Media SDK)'
[12:26:04] comb detect: heavy 0 | light 0 | uncombed 0 | total 0
[12:26:04] decomb: deinterlaced 0 | blended 0 | unfiltered 0 | total 0
[12:26:04] vfr: 0 frames output, 0 dropped and 0 duped for CFR/PFR
[12:26:04] vfr: lost time: 0 (0 frames)
[12:26:04] vfr: gained time: 0 (0 frames) (0 not accounted for)
[12:26:04] adpcm_ima_wav-decoder done: 0 frames, 0 decoder errors
[12:26:04] mpeg4-decoder done: 0 frames, 0 decoder errors
[12:26:04] sync: got 0 frames, 540 expected
[12:26:04] Finished work at: Fri May 15 12:26:04 2020

[12:26:04] libhb: work result = 3

Activity

  1. bradleysepos commented on May 16, 2020

    @bradleysepos
    Contributor

    Thanks for reporting this. It would be good to get a fix in for HandBrake 1.3.3. My only concern is whether we should gate this fix for Gen 9+ only (if we can).

  2. added this to the 1.3.3 milestone on May 16, 2020
  3. bradleysepos commented on May 16, 2020

    @bradleysepos
    Contributor

    Or perhaps we can gate behind the define MFX_ENABLE_HEVCEHW_REFACTORING. So the question would be whether size*2 is appropriate (too much or too little?).

  4. maximd33 commented on May 16, 2020

    @maximd33
    Contributor

    if allocation change as per patch yuichiro-naito@e468a37
    helps, nothing against it
    But please keep one if() and add || / OR condition
    if((pv->param.videoParam->mfx.FrameInfo.FourCC == MFX_FOURCC_P010) || (...))

    @bradleysepos it lives only inside qsv_hevc_make_header() and appropriate size is pretty much guess for the header size.

    thanks for assignment and hope this helps

  5. yuichiro-naito commented on May 17, 2020

    @yuichiro-naito
    ContributorAuthor

    Thanks for reviewing my patch.
    I made a Pull Request that updates my patch to keep one if() statement.
    Please check and see #2862.

  6. bradleysepos commented on Jun 12, 2020

    @bradleysepos
    Contributor

    Closing this as #2862 was merged. Thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions