Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding x265 with Intel Quick Sync + Low Power fails #5932

Open
BiGfReAk1337 opened this issue Apr 9, 2024 · 2 comments
Open

Encoding x265 with Intel Quick Sync + Low Power fails #5932

BiGfReAk1337 opened this issue Apr 9, 2024 · 2 comments

Comments

@BiGfReAk1337
Copy link

Problem Description

Lets say i encode a couple episodes of a season with H.265 (Intel QSV) plus low power quick sync activated in the settings.
A lot of the files finish successfully, but sometimes i get the following error and the encode failes:

[10:39:57] qsv_enc_init: using 'hardware (1) via D3D11' implementation, API: 2.10
Error code -5, hb_qsv_wait_on_sync 601
encqsv: hb_qsv_wait_on_sync failed (-5)
encqsvWork: qsv_enc_work failed -5

Retrying fails again. Restarting Handbrake and retrying fails too.
Deactivating low power quick sync in the settings decreases encoding speed, but the encodes finish successfully.
My system is an ASRock N100M Mainboard with Intel® Quad-Core Processor N100 CPU
It runs on Windows 11 with the latest intel drivers. (311.0.101.5382)

Activity Log, Crash Log or any other details

HandBrake 1.7.3 (2024021000)
OS: Microsoft Windows NT 10.0.22631.0
CPU: Intel(R) N100
Ram: 16173 MB, 
GPU Information:
  IddSampleDriver Device HDR - 23.34.25.279
  Intel(R) UHD Graphics - 31.0.101.5382
Screen: 2560x1440
Temp Dir: C:\Users\xxxxx\AppData\Local\Temp\
Install Dir: C:\Program Files\HandBrake\
Data Dir: C:\Users\xxxxx\AppData\Roaming\HandBrake

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

 # Starting Encode ...

[10:39:54] base preset: 1080p QuickSync 2500kbit
[10:39:54] Remote Process started with Process ID: 2688 using port: 8037. Max Allowed Instances: 1
[10:39:54] Worker: Starting HandBrake Engine ...
[10:39:54] Worker: Parent Process Id 3352
[10:39:54] Worker: Starting Web Server on port 8037 ...
[10:39:54] Worker: Starting Listener: 1
[10:39:54] Worker: Server Started
[10:39:54] Worker: Disconnected worker monitoring enabled!
[10:39:54] Compile-time hardening features are enabled
Cannot load nvEncodeAPI64.dll
[10:39:54] vcn: not available on this system
[10:39:56] qsv: is available on this system
[10:39:56] hb_init: starting libhb thread
[10:39:56] Starting work at: Tue Apr 09 10:39:56 2024
[10:39:56] 1 job(s) to process
[10:39:56] json job:
{
  "Audio": {
    "AudioList": [],
    "CopyMask": [],
    "FallbackEncoder": "none"
  },
  "Destination": {
    "ChapterList": [
      {
        "Name": "Kapitel 1"
      }
    ],
    "ChapterMarkers": true,
    "AlignAVStart": false,
    "File": "Z:\\File - S02E01.mkv",
    "Options": {
      "IpodAtom": false,
      "Optimize": false
    },
    "Mux": "av_mkv"
  },
  "Filters": {
    "FilterList": [
      {
        "ID": 19,
        "Settings": {
          "crop-bottom": "0",
          "crop-left": "0",
          "crop-right": "0",
          "crop-top": "0",
          "height": "1080",
          "width": "1920"
        }
      },
      {
        "ID": 10,
        "Settings": {
          "mode": "1"
        }
      }
    ]
  },
  "PAR": {
    "Num": 1,
    "Den": 1
  },
  "Metadata": {},
  "SequenceID": 0,
  "Source": {
    "Angle": 1,
    "Range": {
      "Type": "chapter",
      "Start": 1,
      "End": 1
    },
    "Title": 1,
    "Path": "C:\\File- S02E01.mkv",
    "HWDecode": 6
  },
  "Subtitle": {
    "Search": {
      "Burn": false,
      "Default": false,
      "Enable": false,
      "Forced": false
    },
    "SubtitleList": []
  },
  "Video": {
    "Encoder": "qsv_h265",
    "Level": "auto",
    "Bitrate": 2500,
    "MultiPass": false,
    "Turbo": false,
    "ColorMatrixCode": 0,
    "Options": "lowpower=1",
    "Preset": "quality",
    "Profile": "auto",
    "QSV": {
      "Decode": true
    },
    "HardwareDecode": 0
  }
}
[10:39:56] CPU: Intel(R) N100
[10:39:56]  - logical processor count: 4
[10:39:56] Intel Quick Sync Video support: yes, gpu list: 0
[10:39:56] Intel Quick Sync Video integrated adapter with index 0
[10:39:56] Impl mfx-gen library path: C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_f0d0eb9243852f17\libmfx64-gen.dll
[10:39:56]  - Intel Media SDK hardware: API 2.10 (minimum: 1.3)
[10:39:56]  - Decode support:  h264 hevc (8bit: yes, 10bit: yes) av1 (8bit: yes, 10bit: yes)
[10:39:56]  - H.264 encoder: yes
[10:39:56]     - preferred implementation: hardware (1) via D3D11
[10:39:56]     - capabilities (hardware):  lowpower breftype icq vsinfo chromalocinfo opt1 opt2+mbbrc+extbrc+trellis+repeatpps+ib_adapt+nmpslice
[10:39:56]  - H.265 encoder: yes (8bit: yes, 10bit: yes)
[10:39:56]     - preferred implementation: hardware (1) via D3D11
[10:39:56]     - capabilities (hardware):  lowpower bpyramid icq vsinfo masteringinfo cllinfo opt1
[10:39:56]  - AV1 encoder: no
[10:39:56] hb_scan: path=C:\File - S02E01.mkv, title_index=1
Input #0, matroska,webm, from 'C:\File - S02E01.mkv':
  Metadata:
    encoder         : libebml v1.4.5 + libmatroska v1.7.1
  Duration: 00:44:11.01, start: 0.000000, bitrate: 8339 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn (default)
    Metadata:
      BPS             : 7825381
      DURATION        : 00:44:11.000000000
      NUMBER_OF_FRAMES: 66275
      NUMBER_OF_BYTES : 2593135880
      _STATISTICS_WRITING_APP: mkvmerge v82.0 ('I'm The President') 64-bit
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  Stream #0:1(ger): Audio: eac3, 48000 Hz, 5.1(side), fltp, 256 kb/s (default)
    Metadata:
      title           : German
      BPS             : 256000
      DURATION        : 00:44:11.008000000
      NUMBER_OF_FRAMES: 82844
      NUMBER_OF_BYTES : 84832256
      _STATISTICS_WRITING_APP: mkvmerge v82.0 ('I'm The President') 64-bit
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  Stream #0:2(eng): Audio: eac3, 48000 Hz, 5.1(side), fltp, 256 kb/s
    Metadata:
      title           : English
      BPS             : 256000
      DURATION        : 00:44:11.008000000
      NUMBER_OF_FRAMES: 82844
      NUMBER_OF_BYTES : 84832256
      _STATISTICS_WRITING_APP: mkvmerge v82.0 ('I'm The President') 64-bit
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  Stream #0:3(ger): Subtitle: subrip (default) (forced)
    Metadata:
      title           : German (Forced)
      BPS             : 1
      DURATION        : 00:40:52.040000000
      NUMBER_OF_FRAMES: 17
      NUMBER_OF_BYTES : 564
      _STATISTICS_WRITING_APP: mkvmerge v82.0 ('I'm The President') 64-bit
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  Stream #0:4(eng): Subtitle: subrip (forced)
    Metadata:
      title           : English (Forced)
      BPS             : 1
      DURATION        : 00:43:31.720000000
      NUMBER_OF_FRAMES: 14
      NUMBER_OF_BYTES : 486
      _STATISTICS_WRITING_APP: mkvmerge v82.0 ('I'm The President') 64-bit
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
  Stream #0:5(eng): Subtitle: subrip
    Metadata:
      title           : English (SDH)
      BPS             : 88
      DURATION        : 00:44:01.240000000
      NUMBER_OF_FRAMES: 689
      NUMBER_OF_BYTES : 29068
      _STATISTICS_WRITING_APP: mkvmerge v82.0 ('I'm The President') 64-bit
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
[10:39:56] scan: decoding previews for title 1
[10:39:56] scan: audio 0x1: eac3, rate=48000Hz, bitrate=256000 Deutsch (E-AC3, 5.1 ch, 256 kbps)
[10:39:56] scan: audio 0x2: eac3, rate=48000Hz, bitrate=256000 English (E-AC3, 5.1 ch, 256 kbps)
[10:39:56] using container PAR 1:1
[10:39:56] scan: 10 previews, 1920x1080, 25.000 fps, autocrop = 0/0/240/240, aspect 16:9, PAR 1:1, color profile: 1-1-1, chroma location: left
[10:39:56] scan: supported video decoders: avcodec qsv
[10:39:56] libhb: scan thread found 1 valid title(s)
[10:39:56] Starting Task: Encoding Pass
[10:39:56] work: skipping crop/scale filter
[10:39:56] work: only 1 chapter, disabling chapter markers
[10:39:56] job configuration:
[10:39:56]  * source
[10:39:56]    + C:\File - S02E01.mkv
[10:39:56]    + title 1, chapter(s) 1 to 1
[10:39:56]    + container: matroska,webm
[10:39:56]    + data rate: 8339 kbps
[10:39:56]  * destination
[10:39:56]    + Z:\File - S02E01.mkv
[10:39:56]    + container: Matroska (libavformat)
[10:39:56]  * video track
[10:39:56]    + decoder: h264_qsv 8-bit (yuv420p)
[10:39:56]    + filters
[10:39:56]      + Framerate Shaper (mode=1)
[10:39:56]        + frame rate: 25.000 fps -> constant 25.000 fps
[10:39:56]      + Format (format=nv12)
[10:39:56]    + Output geometry
[10:39:56]      + storage dimensions: 1920 x 1080
[10:39:56]      + pixel aspect ratio: 1 : 1
[10:39:56]      + display dimensions: 1920 x 1080
[10:39:56]    + encoder: H.265 (Intel Media SDK)
[10:39:56]      + preset:  quality
[10:39:56]      + options: lowpower=1
[10:39:56]      + profile: auto
[10:39:56]      + level:   auto
[10:39:56]      + bitrate: 2500 kbps, pass: 0
[10:39:56]      + color profile: 1-1-1
[10:39:56]      + chroma location: left
[10:39:56] sync: expecting 66275 video frames
[10:39:57] encqsvInit: using encode-only via system memory (LowPower) path
[10:39:57] encqsvInit: H.265/HEVC Main profile @ level 4.0
[10:39:57] encqsvInit: TargetUsage 1 AsyncDepth 6
[10:39:57] encqsvInit: GopRefDist 8 GopPicSize 56 NumRefFrame 4 IdrInterval 0
[10:39:57] encqsvInit: BFramesMax 7 BRefType pyramid
[10:39:57] encqsvInit: RateControlMethod VBR TargetKbps 2500 MaxKbps 2500 BufferSizeInKB 625 InitialDelayInKB 312 BRCParamMultiplier 1
[10:39:57] sync: first pts video is 0
[10:39:57] sync: "Kapitel 1" (1) at frame 1 time 0
[10:39:57] qsv_enc_init: using 'hardware (1) via D3D11' implementation, API: 2.10
Error code -5,	hb_qsv_wait_on_sync	601
encqsv: hb_qsv_wait_on_sync failed (-5)
encqsvWork: qsv_enc_work failed -5
[10:41:58] work: average encoding speed for job is 129.123459 fps
[10:41:58] vfr: 15634 frames output, 0 dropped and 0 duped for CFR/PFR
[10:41:58] vfr: lost time: 0 (0 frames)
[10:41:58] vfr: gained time: 0 (0 frames) (0 not accounted for)
[10:41:58] h264_qsv-decoder done: 15658 frames, 0 decoder errors
[10:41:58] sync: got 15638 frames, 66275 expected
[10:41:58] sync: framerate min 25.000 fps, max 25.000 fps, avg 25.000 fps
[10:41:58] mux: track 0, 15568 frames, 192480794 bytes, 2472.62 kbps, fifo 1024
Error code -1,	hb_qsv_context_clean	245
[10:41:58] Finished work at: Tue Apr 09 10:41:58 2024
[10:41:58] libhb: work result = 4

 # Job Failed (4)

What Operating System are you running?

Windows 11

What version of HandBrake are you running?

1.7.3 (2024021000)

Where did you download HandBrake from?

Handbrake website

@sr55
Copy link
Contributor

sr55 commented Apr 9, 2024

@galinart Any ideas what this might be?

@DOram424
Copy link

DOram424 commented May 3, 2024

I'm just about to submit a patch that may fix this and hopefully it'll be in a nightly build soon. This problem is occuring because handbrake defaults low power to on under windows (it's off under linux) and the handbrake capability checking code is bugging out when the encoder init it uses always fails. Post that patch it will only be possible to experiment with low power by passing handbrake the lowpower=on parameter (use -x in HandbrakeCLI or the box in ghb). It should no longer crash provided your hardware/firmware supports low power encoding for the selected handbrake rate control method and codec. If it isn't supported the encode will fail, but hopefully only if you've used the lowpower=on user supplied parameter. With my 13th gen desktop CPU handbrake I can do a low power CQP HEVC encode that previously ran at 60fps at around 300fps so it should be bleeding obvious if you get it working.

This probably isn't the place to suggest or discuss this but I'll likely disappear so you'll have to forgive me. I would presume that low power is not officially supported by handbrake so experimentation is entirely on you .. as is messing with any internal parameters. To encode at low power with the patch I have to use "force-cqp=1" parameter as my 13th gen desktop intel cpu doesn't offer low power ICQ hevc encoding, but does offer CQP. The low power CQP encoder is basically the same as the high power one and is as good as ICQ if you force it to use a much longer GOP parameter than the default handbrake uses. If you run handbrake with the spec. limit for image feature tracks (256 frames) at worst you'll hopefully get a longer than default GOP length that produces better encodes and handbrake will just restrict it to the highest value it's willing to use.

"force-cqp=1:gop-ref-dist=256:gop-pic-size=512:lowpower=1"

Using this makes it work a bit better but without patching handbrake so the full 256 frames are used by the encoder would I expect CQP to be visibly as good as ICQ. For now at least, your best bet for offline archival encoding is the default ICQ hevc which doesn't have a hierarchical B tree so isn't reliant on powers of 2 gop-ref-dist for each layer. It's also the case that a decoder which doesn't support the 256 image feature track required by gop-ref-dist=256 is just not specification compliant and so there's no reason to ever use anything except gop-ref-dist 256 unless you have bitrate or encoder/decoder lag constraints. With as long a GOP as possible the intel codec usually beats out the software encoder, not only in qualitative quality and file sizes, but in number of degrees the CPU has heated the room.

This was referenced May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants
@sr55 @BiGfReAk1337 @DOram424 and others