NVidia NVENC encoder with Handbrake CLI

Discussion of the HandBrake command line interface (CLI)
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.
AndyA
Posts: 12
Joined: Mon Apr 10, 2017 5:45 pm

NVidia NVENC encoder with Handbrake CLI

Post by AndyA »

Description of problem or question:

The CLI documentation doesn't list the Nvidia NVEnc option strings for h264/h265. It does show up in the GUI and the difference in encode times between h264 and h264 NVEnc with similar settings is dramatic with my GTX 980 using the GUI.

I looked through some source code and found things like this:
https://github.com/HandBrake/HandBrake/ ... b/common.c

The codecs are referenced as:
"H.264 (NVEnc)", "nvenc_h264"
"H.265 (NVEnc)", "nvenc_h265"

However when I used nvenc_h264 with the --encoder option and got this -
ERROR: Invalid video encoder (nvenc_h264)

Steps to reproduce the problem (If Applicable):

Run handbrake CLI with one of the NVEnc encoders on a Windows 10 machine with a support NVidia video card.

HandBrake version (e.g., 1.0.0):

1.2.0

Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):

Windows 10 1803
NVidia GTX 980 Driver 397.93

HandBrake Activity Log ***required*** (see How-to get an activity log)

[13:24:45] hb_init: starting libhb thread
[13:24:45] thread 2fa5240 started ("libhb")
HandBrake 1.0.3 (2017022500) - MinGW x86_64 - https://handbrake.fr
12 CPUs detected
Opening D:\Movies\MyMovie...
[13:24:45] CPU: Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz
[13:24:45] - Intel microarchitecture Broadwell
[13:24:45] - logical processor count: 12
[13:24:45] Intel Quick Sync Video support: no
[13:24:45] hb_scan: path=D:\Movies\MyMovie), title_index=0

Scanning title 1 of 1, 0.00 %

...

Scanning title 2 of 2, preview 10, 100.00 %[13:24:48] scan: 10 previews, 1920x1080, 23.976 fps, autocrop = 140/140/0/0, aspect 16:9, PAR 1:1
[13:24:48] scan: supported video decoders: avcodec qsv
[13:24:48] stream: 5 good frames, 0 errors (0%)
[13:24:48] libhb: scan thread found 2 valid title(s)
Searching for main feature title...
+ Title (0) index 1 has length 6728sec
+ Title (1) index 153 has length 6728sec
Found main feature title 153
+ Using preset: CLI Default
+ title 153:
+ Main Feature
+ playlist: 00357.MPLS
+ duration: 01:52:08
+ size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 23.976 fps
+ autocrop: 140/140/0/0
+ support opencl: no
+ chapters:
+ 1: cells 0->0, 0 blocks, duration 00:02:35

...

+ 36: cells 0->0, 0 blocks, duration 00:24:47
+ audio tracks:
+ 1, English (DTS) (5.1 ch) (iso639-2: eng), 48000Hz, 1536000bps
+ 2, English (DTS-HD MA) (5.1 ch) (iso639-2: eng)
+ 3, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 640000bps
+ 4, Francais (DTS) (5.1 ch) (iso639-2: fra), 48000Hz, 1536000bps
+ 5, Francais (DTS-HD MA) (5.1 ch) (iso639-2: fra)
+ 6, Francais (AC3) (5.1 ch) (iso639-2: fra), 48000Hz, 640000bps
+ 7, español (AC3) (5.1 ch) (iso639-2: spa), 48000Hz, 640000bps
+ subtitle tracks:
+ 1, English (iso639-2: eng) (Bitmap)(PGS)
+ 2, English (iso639-2: eng) (Bitmap)(PGS)
+ 3, Francais (iso639-2: fra) (Bitmap)(PGS)
+ 4, español (iso639-2: spa) (Bitmap)(PGS)
+ 5, Francais (iso639-2: fra) (Bitmap)(PGS)
ERROR: Invalid video encoder (nvenc_h264)
Failed to initialize job
HandBrake has exited.
Last edited by AndyA on Sun Feb 10, 2019 11:18 pm, edited 2 times in total.
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by mduell »

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.
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: NVidia NVENC encoder with Handbrake CLI

Post by Woodstock »

The NVENC encoders aren't valid if handbrake doesn't detect the hardware; Your log would show whether or not the hardware is "there" for the software.
AndyA
Posts: 12
Joined: Mon Apr 10, 2017 5:45 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by AndyA »

Woodstock the nvenc encoder options are available in the GUI and the documentation says they won't be available if the video card doesn't support it.

https://handbrake.fr/docs/en/latest/tec ... nvenc.html

Not only was it a lot faster using nvenc in the GUI I also saw the GPU usage in the Windows 10 task manager.
Last edited by AndyA on Sun Feb 10, 2019 11:22 pm, edited 3 times in total.
AndyA
Posts: 12
Joined: Mon Apr 10, 2017 5:45 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by AndyA »

Mduell that line is the only thing relevant from the log.
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by mduell »

HandBrake version (e.g., 1.0.0):

1.2.0

Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):

Windows 10 1803
NVidia GTX 980 Driver 397.93

HandBrake Activity Log ***required*** (see How-to get an activity log)

[13:24:45] hb_init: starting libhb thread
[13:24:45] thread 2fa5240 started ("libhb")
HandBrake 1.0.3 (2017022500) - MinGW x86_64 - https://handbrake.fr
This is exactly why logs are required, and you can get faster and more relevant help by providing them.

You're using the 1.0.3 CLI, which does not support NVENC. Upgrade to the 1.2.0 CLI for NVENC.
AndyA
Posts: 12
Joined: Mon Apr 10, 2017 5:45 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by AndyA »

mduell, fair enough! Darnit, what happened was I had downloaded the latest handbrake CLI but put it in a different spot and my script still referenced the old and I didn't realize it. 1.2.0 finds nvenc_h264!

I still might have some trouble with it working, I'm looking at it now.
AndyA
Posts: 12
Joined: Mon Apr 10, 2017 5:45 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by AndyA »

Now that I'm using the right CLI version I'm getting this error. First log is the GUI 1.2.0 (works), second is the CLI 1.2.0 (failed).


GUI Log

HandBrake 1.2.0 (2018121700)
OS: Microsoft Windows NT 10.0.17134.0
Ram: 65432 MB,
GPU Information:
NVIDIA GeForce GTX 980 - 24.21.13.9793
Screen: 1920x1200
Temp Dir: C:\Users\andya\AppData\Local\Temp\
Install Dir: C:\Program Files\HandBrake
Data Dir: C:\Users\andya\AppData\Roaming\HandBrake

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


# Starting Encode ...

[18:46:27] hb_init: starting libhb thread
[18:46:27] 1 job(s) to process
[18:46:27] json job:
{
"Audio": {
"AudioList": [
{
"Bitrate": 160,
"DRC": 0.0,
"Encoder": "av_aac",
"Gain": 0.0,
"Mixdown": 6,
"NormalizeMixLevel": false,
"Samplerate": 0,
"Track": 0,
"DitherMethod": 0
},
{
"DRC": 0.0,
"Encoder": "copy:ac3",
"Gain": 0.0,
"Mixdown": -1,
"NormalizeMixLevel": false,
"Samplerate": 0,
"Track": 0,
"DitherMethod": 0
}
],
"CopyMask": [
"copy:aac",
"copy:ac3",
"copy:dtshd",
"copy:dts",
"copy:eac3",
"copy:flac",
"copy:mp3",
"copy:truehd"
],
"FallbackEncoder": "ac3"
},
"Destination": {
"ChapterList": [
{
"Name": "Chapter 1"
},

...

],
"ChapterMarkers": true,
"AlignAVStart": false,
"File": "C:\\Users\\andya\\Desktop\\test.mp4",
"Mp4Options": {
"IpodAtom": false,
"Mp4Optimize": false
},
"Mux": "mp4"
},
"Filters": {
"FilterList": [
{
"ID": 4,
"Settings": {
"mode": "7"
}
},
{
"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": 11,
"Settings": {
"crop-bottom": "144",
"crop-left": "0",
"crop-right": "0",
"crop-top": "142",
"height": "794",
"width": "1920"
}
},
{
"ID": 6,
"Settings": {
"mode": "2",
"rate": "27000000/900000"
}
}
]
},
"PAR": {
"Num": 1,
"Den": 1
},
"Metadata": {},
"SequenceID": 0,
"Source": {
"Angle": 1,
"Range": {
"Type": "chapter",
"Start": 1,
"End": 1
},
"Title": 1,
"Path": "D:\\Movies\\MyMovie"
},
"Subtitle": {
"Search": {
"Burn": true,
"Default": false,
"Enable": true,
"Forced": true
},
"SubtitleList": []
},
"Video": {
"Encoder": "nvenc_h264",
"Level": "auto",
"TwoPass": false,
"Turbo": false,
"ColorMatrixCode": 0,
"Options": "",
"Preset": "slow",
"Profile": "high",
"Quality": 18.0,
"QSV": {
"Decode": false,
"AsyncDepth": 0
}
}
}
[18:46:27] CPU: Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz
[18:46:27] - Intel microarchitecture Broadwell
[18:46:27] - logical processor count: 12
[18:46:27] Intel Quick Sync Video support: no
[18:46:27] hb_scan: path=D:\Movies\MyMovie, title_index=1
[18:46:27] scan: BD has 19 title(s)
[18:46:27] bd: scanning title 1
[18:46:27] bd: playlist 00000.MPLS
[18:46:27] bd: duration is 03:00:25 (10825689 ms)
[18:46:27] bd: video id=0x1011, stream type=VC-1, format 1080p
[18:46:27] bd: aspect = 16:9
[18:46:27] bd: audio id=0x1100, lang=English (AC3), 3cc=eng

...

[18:46:27] bd: title 1 has 47 chapters
[18:46:27] scan: decoding previews for title 1
[18:46:27] scan: title angle(s) 1
[18:46:27] scan: audio 0x1100: ac3, rate=48000Hz, bitrate=640000 English (AC3) (5.1 ch)
[18:46:27] scan: audio 0x761101: ac3, rate=48000Hz, bitrate=640000 English (AC3) (5.1 ch)
[18:46:27] scan: audio 0x1102: ac3, rate=48000Hz, bitrate=640000 Francais (AC3) (5.1 ch)
[18:46:27] scan: audio 0x1103: ac3, rate=48000Hz, bitrate=640000 Deutsch (AC3) (5.1 ch)
[18:46:27] scan: audio 0x1104: ac3, rate=48000Hz, bitrate=640000 italiano (AC3) (5.1 ch)
[18:46:27] scan: audio 0x1105: ac3, rate=48000Hz, bitrate=640000 español (AC3) (5.1 ch)
[18:46:27] scan: audio 0x1106: ac3, rate=48000Hz, bitrate=192000 English (AC3) (1.0 ch)
[18:46:27] scan: audio 0x721101: truehd, rate=48000Hz, bitrate=128000 English (TrueHD) (5.1 ch)
[18:46:28] scan: 10 previews, 1920x1080, 23.976 fps, autocrop = 142/144/0/0, aspect 16:9, PAR 1:1
[18:46:28] stream: 7 good frames, 0 errors (0%)
[18:46:28] libhb: scan thread found 1 valid title(s)
[18:46:28] starting job
[18:46:28] decomb filter thread started for segment 0

...

[18:46:28] mask filter thread started for segment 3
[18:46:28] job configuration:
[18:46:28] * source
[18:46:28] + D:\Movies\MyMovie
[18:46:28] mask filter thread started for segment 4
[18:46:28] + title 1, chapter(s) 1 to 1
[18:46:28] * destination
[18:46:28] + C:\Users\andya\Desktop\test.mp4
[18:46:28] + container: MPEG-4 (libavformat)
[18:46:28] * video track
[18:46:28] + decoder: vc1
[18:46:28] + bitrate 200 kbps
[18:46:28] + filters
[18:46:28] + 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)
[18:46:28] mask filter thread started for segment 5
[18:46:28] + Decomb (mode=39)
[18:46:28] + Framerate Shaper (mode=2:rate=27000000/900000)
[18:46:28] + frame rate: 23.976 fps -> peak rate limited to 30.000 fps
[18:46:28] + Crop and Scale (width=1920:height=794:crop-top=142:crop-bottom=144:crop-left=0:crop-right=0)
[18:46:28] mask filter thread started for segment 6
[18:46:28] + source: 1920 * 1080, crop (142/144/0/0): 1920 * 794, scale: 1920 * 794
[18:46:28] + Output geometry
[18:46:28] + storage dimensions: 1920 x 794
[18:46:28] + pixel aspect ratio: 1 : 1
[18:46:28] + display dimensions: 1920 x 794
[18:46:28] * Foreign Audio Search: Render/Burn-in, Forced Only
[18:46:28] + subtitle, English [PGS] (track 1, id 0x1201, Picture)
[18:46:28] mask filter thread started for segment 7

...

[18:46:28] sync: expecting 6798 video frames
[18:46:32] reader: end of chapter 1 (media 1) reached at media chapter 2
[18:46:32] reader: done. 1 scr changes
[18:46:33] work: average encoding speed for job is 0.000000 fps
[18:46:33] comb detect: heavy 0 | light 0 | uncombed 0 | total 0
[18:46:33] decomb: deinterlaced 0 | blended 0 | unfiltered 0 | total 0
[18:46:33] vfr: 0 frames output, 0 dropped and 0 duped for CFR/PFR
[18:46:33] vfr: lost time: 0 (0 frames)
[18:46:33] vfr: gained time: 0 (0 frames) (0 not accounted for)
[18:46:33] stream: 6800 good frames, 0 errors (0%)
[18:46:33] vc1-decoder done: 0 frames, 0 decoder errors
[18:46:33] sync: got 0 frames, 6798 expected
[18:46:33] Subtitle track 1 (id 0x1201) 'English [PGS]': 22 hits (0 forced)
[18:46:33] No candidate detected during subtitle scan
[18:46:33] starting job
[18:46:33] decomb filter thread started for segment 0

...

[18:46:33] work: only 1 chapter, disabling chapter markers
[18:46:33] job configuration:
[18:46:33] * source
[18:46:33] + D:\Movies\MyMovie
[18:46:33] mask filter thread started for segment 2
[18:46:33] + title 1, chapter(s) 1 to 1
[18:46:33] * destination
[18:46:33] + C:\Users\andya\Desktop\test.mp4
[18:46:33] + container: MPEG-4 (libavformat)
[18:46:33] * video track
[18:46:33] + decoder: vc1
[18:46:33] mask filter thread started for segment 3
[18:46:33] + bitrate 200 kbps
[18:46:33] + filters
[18:46:33] + 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)
[18:46:33] mask filter thread started for segment 4
[18:46:33] + Decomb (mode=39)
[18:46:33] + Framerate Shaper (mode=2:rate=27000000/900000)
[18:46:33] + frame rate: 23.976 fps -> peak rate limited to 30.000 fps
[18:46:33] + Crop and Scale (width=1920:height=794:crop-top=142:crop-bottom=144:crop-left=0:crop-right=0)
[18:46:33] + source: 1920 * 1080, crop (142/144/0/0): 1920 * 794, scale: 1920 * 794
[18:46:33] + Output geometry
[18:46:33] + storage dimensions: 1920 x 794
[18:46:33] + pixel aspect ratio: 1 : 1
[18:46:33] mask filter thread started for segment 5
[18:46:33] + display dimensions: 1920 x 794
[18:46:33] + encoder: H.264 (NVEnc)
[18:46:33] + preset: slow
[18:46:33] + profile: high
[18:46:33] mask filter thread started for segment 6
[18:46:33] + level: auto
[18:46:33] + quality: 18.00 (CQ)
[18:46:33] + color profile: 1-1-1
[18:46:33] * audio track 1
[18:46:33] + decoder: English (AC3) (5.1 ch) (track 1, id 0x1100)
[18:46:33] + bitrate: 640 kbps, samplerate: 48000 Hz
[18:46:33] mask filter thread started for segment 7
[18:46:33] + mixdown: Dolby Pro Logic II
[18:46:33] + dither: none
[18:46:33] + encoder: AAC (libavcodec)
[18:46:33] + bitrate: 160 kbps, samplerate: 48000 Hz
[18:46:33] * audio track 2
[18:46:33] + decoder: English (AC3) (5.1 ch) (track 1, id 0x1100)
[18:46:33] + bitrate: 640 kbps, samplerate: 48000 Hz
[18:46:33] + AC3 Passthru
[18:46:33] mask filter thread started for segment 8

...

[18:46:33] yadif thread started for segment 11
[18:46:33] sync: expecting 6798 video frames
[18:46:33] encavcodecInit: H.264 (Nvidia NVENC)
[18:46:33] encavcodec: encoding at rc=constqp QP 18.00
[18:46:33] encavcodec: encoding with stored aspect 1/1
[18:46:33] sync: first pts video is 0
[18:46:33] sync: "Chapter 1" (1) at frame 1 time 0
[18:46:33] sync: first pts audio 0x1100 is 0
[18:46:33] sync: first pts audio 0x1100 is 0
[18:47:57] reader: end of chapter 1 (media 1) reached at media chapter 2
[18:47:57] reader: done. 1 scr changes
[18:47:57] work: average encoding speed for job is 80.234436 fps
[18:47:58] comb detect: heavy 14 | light 46 | uncombed 6738 | total 6798
[18:47:58] decomb: deinterlaced 14 | blended 46 | unfiltered 6738 | total 6798
[18:47:58] vfr: 6798 frames output, 0 dropped and 0 duped for CFR/PFR
[18:47:58] vfr: lost time: 0 (0 frames)
[18:47:58] vfr: gained time: 0 (0 frames) (0 not accounted for)
[18:47:58] stream: 6800 good frames, 0 errors (0%)
[18:47:58] ac3-decoder done: 8839 frames, 0 decoder errors
[18:47:58] ac3-decoder done: 8839 frames, 0 decoder errors
[18:47:58] vc1-decoder done: 6798 frames, 0 decoder errors
[18:47:58] sync: got 6798 frames, 6798 expected
[18:47:58] sync: framerate min 23.981 fps, max 23.981 fps, avg 23.976 fps
[aac @ 000001d872466740] Qavg: 4502.812
[18:47:58] mux: track 0, 6798 frames, 363249721 bytes, 10249.23 kbps, fifo 512
[18:47:58] mux: track 1, 13259 frames, 5323418 bytes, 150.20 kbps, fifo 1024
[18:47:58] mux: track 2, 8839 frames, 22627840 bytes, 638.45 kbps, fifo 1024
[18:47:58] libhb: work result = 0

# Encode Completed ...



CLI Log



& "C:\Program Files\HandBrakeCLI.exe" --aencoder copy --audio-copy-mask dts,dtshd,eac3,aac,ac3 --audio-fallback ac3 --mixdown 5point1 --ab 768 --
normalize-mix 1 --output "D:\Movies-MKV\Movies\MyMovie - copyaudio.mkv" --markers --format av_mkv --input "D:\Movies\MyMovie" --title 1 --encoder nvenc_h26
4 --quality 18 --encoder-preset slow --encoder-profile high --encoder-level auto --vfr
[18:50:32] hb_init: starting libhb thread
[18:50:32] thread 433e070 started ("libhb")
HandBrake 1.2.0 (2018121700) - MinGW x86_64 - https://handbrake.fr
12 CPUs detected
Opening D:\Movies\MyMovie...
[18:50:32] CPU: Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz
[18:50:32] - Intel microarchitecture Broadwell
[18:50:32] - logical processor count: 12
[18:50:32] Intel Quick Sync Video support: no
[18:50:32] hb_scan: path=D:\Movies\MyMovie, title_index=1
[18:50:32] scan: BD has 19 title(s)
[18:50:32] bd: scanning title 1
[18:50:32] bd: playlist 00000.MPLS
[18:50:32] bd: duration is 03:00:25 (10825689 ms)
[18:50:32] bd: video id=0x1011, stream type=VC-1, format 1080p
[18:50:32] bd: aspect = 16:9
[18:50:32] bd: audio id=0x1100, lang=English (AC3), 3cc=eng

...

[18:50:32] bd: chap 1 packet=960, 283574 ms

...

[18:50:32] bd: title 1 has 47 chapters
[18:50:32] scan: decoding previews for title 1
[18:50:32] scan: title angle(s) 1
[18:50:32] scan: audio 0x1100: ac3, rate=48000Hz, bitrate=640000 English (AC3) (5.1 ch)
[18:50:32] scan: audio 0x761101: ac3, rate=48000Hz, bitrate=640000 English (AC3) (5.1 ch)
[18:50:32] scan: audio 0x1102: ac3, rate=48000Hz, bitrate=640000 Francais (AC3) (5.1 ch)
[18:50:32] scan: audio 0x1103: ac3, rate=48000Hz, bitrate=640000 Deutsch (AC3) (5.1 ch)
[18:50:32] scan: audio 0x1104: ac3, rate=48000Hz, bitrate=640000 italiano (AC3) (5.1 ch)
[18:50:32] scan: audio 0x1105: ac3, rate=48000Hz, bitrate=640000 español (AC3) (5.1 ch)
[18:50:32] scan: audio 0x1106: ac3, rate=48000Hz, bitrate=192000 English (AC3) (1.0 ch)
[18:50:32] scan: audio 0x721101: truehd, rate=48000Hz, bitrate=128000 English (TrueHD) (5.1 ch)
Scanning title 1 of 1, preview 8, 80.00 %[18:50:32] scan: 10 previews, 1920x1080, 23.976 fps, autocrop = 142/144/0/0, aspect 16:9, PAR 1:1
[18:50:32] stream: 7 good frames, 0 errors (0%)
[18:50:32] libhb: scan thread found 1 valid title(s)
+ Using preset: CLI Default
+ title 1:
+ playlist: 00000.MPLS
+ duration: 03:00:25
+ size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 23.976 fps
+ autocrop: 142/144/0/0
+ chapters:
+ 1: cells 0->0, 0 blocks, duration 00:04:44

...

+ audio tracks:
+ 1, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 640000bps
+ 2, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 640000bps
+ 3, English (TrueHD) (5.1 ch) (iso639-2: eng)
+ 4, Francais (AC3) (5.1 ch) (iso639-2: fra), 48000Hz, 640000bps
+ 5, Deutsch (AC3) (5.1 ch) (iso639-2: deu), 48000Hz, 640000bps
+ 6, italiano (AC3) (5.1 ch) (iso639-2: ita), 48000Hz, 640000bps
+ 7, espa├▒ol (AC3) (5.1 ch) (iso639-2: spa), 48000Hz, 640000bps
+ 8, English (AC3) (1.0 ch) (iso639-2: eng), 48000Hz, 192000bps
+ subtitle tracks:
+ 1, 日本語 [PGS]
+ 2, English [PGS]
+ 3, 日本語 [PGS]
+ 4, Francais [PGS]
+ 5, Deutsch [PGS]
+ 6, italiano [PGS]
+ 7, italiano [PGS]
+ 8, espa├▒ol [PGS]
+ 9, Nederlands [PGS]
+ 10, 한국어 [PGS]
+ 11, espa├▒ol [PGS]
+ 12, Portugues [PGS]
+ 13, dansk [PGS]
+ 14, suomi [PGS]
+ 15, norsk [PGS]
+ 16, polski [PGS]
+ 17, Portugues [PGS]
+ 18, svenska [PGS]
+ 19, 한국어 [PGS]
[18:50:33] 1 job(s) to process
[18:50:33] json job:
{
"Audio": {
"AudioList": [
{
"Bitrate": 0,
"DRC": 0.0,
"Encoder": "copy:ac3",
"Mixdown": "none",
"PresetEncoder": "copy",
"Quality": -3.0,
"Samplerate": 0,
"Track": 0
}
],
"CopyMask": [
"copy:dts",
"copy:dtshd",
"copy:eac3",
"copy:aac",
"copy:ac3"
],
"FallbackEncoder": "ac3"
},
"Destination": {
"AlignAVStart": false,
"ChapterList": [
{
"Name": "Chapter 1"
},

...


],
"ChapterMarkers": true,
"File": "D:\\Movies-MKV\\Movies\\MyMovie - copyaudio.mkv",
"InlineParameterSets": false,
"Mp4Options": {
"IpodAtom": false,
"Mp4Optimize": false
},
"Mux": "mkv"
},
"Filters": {
"FilterList": [
{
"ID": 6,
"Settings": {
"mode": 0
}
},
{
"ID": 11,
"Settings": {
"crop-bottom": 144,
"crop-left": 0,
"crop-right": 0,
"crop-top": 142,
"height": 794,
"width": 1920
}
}
]
},
"Metadata": {},
"PAR": {
"Den": 1,
"Num": 1
},
"SequenceID": 0,
"Source": {
"Angle": 0,
"Path": "D:\\Movies\\MyMovie",
"Range": {
"End": 47,
"Start": 1,
"Type": "chapter"
},
"Title": 1
},
"Subtitle": {
"Search": {
"Burn": true,
"Default": false,
"Enable": false,
"Forced": false
},
"SubtitleList": []
},
"Video": {
"ColorMatrix": 1,
"ColorPrimaries": 1,
"ColorTransfer": 1,
"Encoder": "nvenc_h264",
"Level": "auto",
"Preset": "slow",
"Profile": "high",
"QSV": {
"AsyncDepth": 4,
"Decode": false
},
"Quality": 18.0,
"Turbo": false,
"TwoPass": false
}
}
[18:50:33] starting job
[18:50:33] job configuration:
[18:50:33] * source
[18:50:33] + D:\Movies\MyMovie
[18:50:33] + title 1, chapter(s) 1 to 47
[18:50:33] * destination
[18:50:33] + D:\Movies-MKV\Movies\MyMovie - copyaudio.mkv
[18:50:33] + container: Matroska (libavformat)
[18:50:33] + chapter markers
[18:50:33] * video track
[18:50:33] + decoder: vc1
[18:50:33] + bitrate 200 kbps
[18:50:33] + filters
[18:50:33] + Framerate Shaper (mode=0)
[18:50:33] + frame rate: same as source (around 23.976 fps)
[18:50:33] + Crop and Scale (width=1920:height=794:crop-top=142:crop-bottom=144:crop-left=0:crop-right=0)
[18:50:33] + source: 1920 * 1080, crop (142/144/0/0): 1920 * 794, scale: 1920 * 794
[18:50:33] + Output geometry
[18:50:33] + storage dimensions: 1920 x 794
[18:50:33] + pixel aspect ratio: 1 : 1
[18:50:33] + display dimensions: 1920 x 794
[18:50:33] + encoder: H.264 (NVEnc)
[18:50:33] + preset: slow
[18:50:33] + profile: high
[18:50:33] + level: auto
[18:50:33] + quality: 18.00 (CQ)
[18:50:33] + color profile: 1-1-1
[18:50:33] * audio track 1
[18:50:33] + decoder: English (AC3) (5.1 ch) (track 1, id 0x1100)
[18:50:33] + bitrate: 640 kbps, samplerate: 48000 Hz
[18:50:33] + AC3 Passthru
[18:50:33] sync: expecting 259556 video frames
[18:50:33] encavcodecInit: H.264 (Nvidia NVENC)
[18:50:33] encavcodec: encoding at rc=constqp QP 18.00
[18:50:33] encavcodec: encoding with stored aspect 1/1
Encoding: task 1 of 1, 0.00 %[h264_nvenc @ 0000000006f37240] Failed creating CUDA context for NVENC: 0x3e7
[h264_nvenc @ 0000000006f37240] No NVENC capable devices found
[18:50:33] encavcodecInit: avcodec_open failed
ERROR: Failure to initialise thread 'FFMPEG encoder (libavcodec)'
[18:50:33] vfr: lost time: 0 (0 frames)
[18:50:33] vfr: gained time: 0 (0 frames) (0 not accounted for)
[18:50:33] ac3-decoder done: 0 frames, 0 decoder errors
[18:50:33] vc1-decoder done: 0 frames, 0 decoder errors
[18:50:33] sync: got 0 frames, 259556 expected
Encoding: task 1 of 1, 0.00 %[18:50:33] libhb: work result = 3

Encode failed (error 3).

HandBrake has exited.
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: NVidia NVENC encoder with Handbrake CLI

Post by Woodstock »

Code: Select all

[18:50:33] encavcodecInit: H.264 (Nvidia NVENC)
[18:50:33] encavcodec: encoding at rc=constqp QP 18.00
[18:50:33] encavcodec: encoding with stored aspect 1/1
Encoding: task 1 of 1, 0.00 %[h264_nvenc @ 0000000006f37240] Failed creating CUDA context for NVENC: 0x3e7
[h264_nvenc @ 0000000006f37240] No NVENC capable devices found
[18:50:33] encavcodecInit: avcodec_open failed
ERROR: Failure to initialise thread 'FFMPEG encoder (libavcodec)'
The CLI was not able to find your encoder. Are these encodes done on the same computer?
AndyA
Posts: 12
Joined: Mon Apr 10, 2017 5:45 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by AndyA »

Woodstock, yea both outputs are from the same machine. Both run as non-elevated process.
AndyA
Posts: 12
Joined: Mon Apr 10, 2017 5:45 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by AndyA »

Phew... Just went through hell lol. I started googling the CLI error and noticed some talk about the nvidia driver so I checked and noticed my drivers were out of date so I updated them... Afterward, my computer wouldn't boot! ugh... Long story short and after a complete rebuild (and up to date nvidia drivers) the CLI is now using NVenc GPU encoder! I'm getting 103 FPS average with high settings! (see below)

--quality 18
--encoder-preset slow
--encoder-profile high
--encoder-level auto
DavidIrwin
Posts: 9
Joined: Sun Apr 16, 2017 7:56 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by DavidIrwin »

I realise I am now taking your original post slightly off-topic but I am looking at a similar setup and wondering if things are working right.

From a HB log this is my hardware details.

Code: Select all

HandBrake 1.2.0 (2018121700)
OS: Microsoft Windows NT 10.0.17763.0
Ram: 16215 MB, 
GPU Information:
  Intel(R) HD Graphics 4400 - 20.19.15.4835
  NVIDIA GeForce GTX 1060 6GB - 25.21.14.1735
I am test encoding the same file and getting the following performance:
~150 FPS using Intel QSV with 80% CPU, 52 % Intel GPU, 8% NVidia GPU usage
~150 FPS using NVenc with 80% CPU, 33% Intel GPU, 13% NVidia GPU usage

Whilst I am happy with the FPS rate I am surprised that the CPU usage is so high and the GPU Video Encoder usage seems so low. Do you see similar?
Log snippets below from using the NVenc encoder.

Code: Select all

[21:38:43] CPU: Intel(R) Core(TM) i3-4170 CPU @ 3.70GHz
[21:38:43]  - Intel microarchitecture Haswell
[21:38:43]  - logical processor count: 4
[21:38:43] Intel Quick Sync Video support: yes
[21:38:43]  - Intel Media SDK hardware: API 1.20 (minimum: 1.3)
[21:38:43]  - H.264 encoder: yes
[21:38:43]     - preferred implementation: hardware (any) via D3D11
[21:38:43]     - capabilities (hardware):  breftype icq+la+i+downs vsinfo opt1 opt2+mbbrc+extbrc+trellis+ib_adapt+nmpslice
[...]
[21:38:43] encavcodecInit: H.264 (Nvidia NVENC)
[21:38:43] encavcodec: encoding at rc=constqp QP 18.00
[21:38:43] encavcodec: encoding with stored aspect 5/6
rollin_eng
Veteran User
Posts: 4840
Joined: Wed May 04, 2011 11:06 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by rollin_eng »

Could you please post the whole log.
User avatar
JohnAStebbins
HandBrake Team
Posts: 5712
Joined: Sat Feb 09, 2008 7:21 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by JohnAStebbins »

"Transcoding" (which is what HandBrake does) involves additional steps. Only the "encode" part may be getting done on the encoder ASIC that is sitting on the same die as your GPU. Transcoding involves decoding source video *and* audio, filter video (deinterlace, scale, etc), encode video and audio. Depending on your settings, some of these additional steps could consume quite a lot of cpu.
DavidIrwin
Posts: 9
Joined: Sun Apr 16, 2017 7:56 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by DavidIrwin »

rollin_eng wrote: Fri Feb 22, 2019 8:17 am Could you please post the whole log.
Couldn't work out how to attach a file so included below.

Code: Select all

HandBrake 1.2.0 (2018121700)
OS: Microsoft Windows NT 10.0.17763.0
Ram: 16215 MB, 
GPU Information:
  Intel(R) HD Graphics 4400 - 20.19.15.4835
  NVIDIA GeForce GTX 1060 6GB - 25.21.14.1735
Screen: 1920x1200
Temp Dir: C:\Users\David\AppData\Local\Temp\
Install Dir: C:\Program Files\Handbrake
Data Dir: C:\Users\David\AppData\Roaming\HandBrake

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


# Starting Encode ...

[21:38:43] hb_init: starting libhb thread
[21:38:43] 1 job(s) to process
[21:38:43] json job:
{
  "Audio": {
    "AudioList": [
      {
        "Bitrate": 160,
        "DRC": 0.0,
        "Encoder": "av_aac",
        "Gain": 0.0,
        "Mixdown": 4,
        "NormalizeMixLevel": false,
        "Samplerate": 48000,
        "Track": 0,
        "DitherMethod": 0
      }
    ],
    "CopyMask": [
      "copy:aac"
    ],
    "FallbackEncoder": "av_aac"
  },
  "Destination": {
    "ChapterList": [
      {
        "Name": "Chapter 1"
      }
    ],
    "ChapterMarkers": true,
    "AlignAVStart": true,
    "File": "\\\\192.168.200.209\\Media\\TV Encoded Output\\Arrow - s7e01 - Inmate 4587.m4v",
    "Mp4Options": {
      "IpodAtom": false,
      "Mp4Optimize": true
    },
    "Mux": "mp4"
  },
  "Filters": {
    "FilterList": [
      {
        "ID": 2,
        "Settings": {}
      },
      {
        "ID": 11,
        "Settings": {
          "crop-bottom": "0",
          "crop-left": "0",
          "crop-right": "0",
          "crop-top": "0",
          "height": "600",
          "width": "1280"
        }
      },
      {
        "ID": 6,
        "Settings": {
          "mode": "0"
        }
      }
    ]
  },
  "PAR": {
    "Num": 5,
    "Den": 6
  },
  "Metadata": {},
  "SequenceID": 0,
  "Source": {
    "Angle": 1,
    "Range": {
      "Type": "chapter",
      "Start": 1,
      "End": 1
    },
    "Title": 2,
    "Path": "\\\\192.168.200.209\\Media\\TV\\Arrow\\Season 7\\Arrow - s7e01 - Inmate 4587.mkv"
  },
  "Subtitle": {
    "Search": {
      "Burn": false,
      "Default": false,
      "Enable": true,
      "Forced": true
    },
    "SubtitleList": []
  },
  "Video": {
    "Encoder": "nvenc_h264",
    "Level": "4.1",
    "TwoPass": false,
    "Turbo": false,
    "ColorMatrixCode": 0,
    "Options": "",
    "Preset": "medium",
    "Profile": "auto",
    "Quality": 18.0,
    "QSV": {
      "Decode": true,
      "AsyncDepth": 0
    }
  }
}
[21:38:43] CPU: Intel(R) Core(TM) i3-4170 CPU @ 3.70GHz
[21:38:43]  - Intel microarchitecture Haswell
[21:38:43]  - logical processor count: 4
[21:38:43] Intel Quick Sync Video support: yes
[21:38:43]  - Intel Media SDK hardware: API 1.20 (minimum: 1.3)
[21:38:43]  - H.264 encoder: yes
[21:38:43]     - preferred implementation: hardware (any) via D3D11
[21:38:43]     - capabilities (hardware):  breftype icq+la+i+downs vsinfo opt1 opt2+mbbrc+extbrc+trellis+ib_adapt+nmpslice
[21:38:43]  - H.265 encoder: no
[21:38:43] hb_scan: path=\\192.168.200.209\Media\TV\Arrow\Season 7\Arrow - s7e01 - Inmate 4587.mkv, title_index=2
udfread ERROR: ECMA 167 Volume Recognition failed
src/libbluray/disc/disc.c:323: failed opening UDF image \\192.168.200.209\Media\TV\Arrow\Season 7\Arrow - s7e01 - Inmate 4587.mkv
src/libbluray/disc/disc.c:424: error opening file BDMV\index.bdmv
src/libbluray/disc/disc.c:424: error opening file BDMV\BACKUP\index.bdmv
[21:38:43] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.0
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
[21:38:43] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from '\\192.168.200.209\Media\TV\Arrow\Season 7\Arrow - s7e01 - Inmate 4587.mkv':
  Metadata:
    ENCODER         : Lavf57.82.100
  Duration: 00:41:39.16, start: 0.000000, bitrate: 3506 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(tv, bt709/unknown/unknown, progressive), 1280x720, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Metadata:
      DURATION        : 00:41:39.163000000
    Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default)
    Metadata:
      DURATION        : 00:41:39.136000000
[21:38:43] scan: decoding previews for title 2
[21:38:43] scan: audio 0x1: ac3, rate=48000Hz, bitrate=384000 Unknown (AC3) (5.1 ch)
[21:38:43] scan: 10 previews, 1280x720, 23.976 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1
[21:38:43] scan: supported video decoders: avcodec qsv
[21:38:43] libhb: scan thread found 1 valid title(s)
[21:38:43] Skipping subtitle scan.  No suitable subtitle tracks.
[21:38:43] starting job
[21:38:43] work: only 1 chapter, disabling chapter markers
[21:38:43] job configuration:
[21:38:43]  * source
[21:38:43]    + \\192.168.200.209\Media\TV\Arrow\Season 7\Arrow - s7e01 - Inmate 4587.mkv
[21:38:43]    + title 2, chapter(s) 1 to 1
[21:38:43]    + container: matroska,webm
[21:38:43]    + data rate: 3506 kbps
[21:38:43]  * destination
[21:38:43]    + \\192.168.200.209\Media\TV Encoded Output\Arrow - s7e01 - Inmate 4587.m4v
[21:38:43]    + container: MPEG-4 (libavformat)
[21:38:43]      + optimized for HTTP streaming (fast start)
[21:38:43]      + align initial A/V stream timestamps
[21:38:43]  * video track
[21:38:43]    + decoder: h264_qsv
[21:38:43]    + filters
[21:38:43]      + Detelecine (pullup) ()
[21:38:43]      + Framerate Shaper (mode=0)
[21:38:43]        + frame rate: same as source (around 23.976 fps)
[21:38:43]      + Crop and Scale (width=1280:height=600:crop-top=0:crop-bottom=0:crop-left=0:crop-right=0)
[21:38:43]        + source: 1280 * 720, crop (0/0/0/0): 1280 * 720, scale: 1280 * 600
[21:38:43]    + Output geometry
[21:38:43]      + storage dimensions: 1280 x 600
[21:38:43]      + pixel aspect ratio: 5 : 6
[21:38:43]      + display dimensions: 1066 x 600
[21:38:43]    + encoder: H.264 (NVEnc)
[21:38:43]      + preset:  medium
[21:38:43]      + profile: auto
[21:38:43]      + level:   4.1
[21:38:43]      + quality: 18.00 (CQ)
[21:38:43]      + color profile: 1-1-1
[21:38:43]  * audio track 1
[21:38:43]    + decoder: Unknown (AC3) (5.1 ch) (track 1, id 0x1)
[21:38:43]      + bitrate: 384 kbps, samplerate: 48000 Hz
[21:38:43]    + mixdown: Stereo
[21:38:43]    + dither: none
[21:38:43]    + encoder: AAC (libavcodec)
[21:38:43]      + bitrate: 160 kbps, samplerate: 48000 Hz
[21:38:43] sync: expecting 59919 video frames
[21:38:43] encavcodecInit: H.264 (Nvidia NVENC)
[21:38:43] encavcodec: encoding at rc=constqp QP 18.00
[21:38:43] encavcodec: encoding with stored aspect 5/6
[21:38:44] sync: first pts video is 0
[21:38:44] sync: "Chapter 1" (1) at frame 1 time 0
[21:38:44] sync: first pts audio 0x1 is 0
[21:45:14] reader: done. 1 scr changes
[21:45:14] work: average encoding speed for job is 153.425858 fps
[21:45:14] vfr: lost time: 33785 (0 frames)
[21:45:14] vfr: gained time: 33785 (28 frames) (0 not accounted for)
[21:45:15] ac3-decoder done: 78098 frames, 0 decoder errors
[21:45:15] h264_qsv-decoder done: 59920 frames, 0 decoder errors
[21:45:15] sync: got 59920 frames, 59919 expected
[21:45:15] sync: framerate min 23.981 fps, max 23.981 fps, avg 23.976 fps
[21:45:40] mux: track 0, 59911 frames, 1051538941 bytes, 3366.05 kbps, fifo 2048
[21:45:40] mux: track 1, 117148 frames, 50186896 bytes, 160.65 kbps, fifo 4096
[21:45:40] libhb: work result = 0

# Encode Completed ...

User avatar
s55
HandBrake Team
Posts: 10350
Joined: Sun Dec 24, 2006 1:05 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by s55 »

CPU usage is in the Filters, Audio Encoding, A/V Sync etc. This is normal.

I'd say your CPU is actually bottle necking you here. If you don't need the filters, turn them off to release some more potential.
DavidIrwin
Posts: 9
Joined: Sun Apr 16, 2017 7:56 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by DavidIrwin »

s55 wrote: Sat Feb 23, 2019 12:15 pm CPU usage is in the Filters, Audio Encoding, A/V Sync etc. This is normal.

I'd say your CPU is actually bottle necking you here. If you don't need the filters, turn them off to release some more potential.
Thank you for the advice. I will review those settings and see how much faster it all gets.

David
DavidIrwin
Posts: 9
Joined: Sun Apr 16, 2017 7:56 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by DavidIrwin »

So, turned off the Detelecine and Deinterlace and now up to 300 FPS which is going to make short work of my re-encoding requirements. Still seeing ~90% CPU usage so assume this is about the audio re-encode now.

I will update again after more testing :)
DavidIrwin
Posts: 9
Joined: Sun Apr 16, 2017 7:56 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by DavidIrwin »

And now ~400 FPS with the audio set to "pass through". Not how I want the files encoded but interesting.

70% CPU, 56% Intel Graphics (decoding), 29% NVidia graphics (encoding). I think the next bottleneck may be that I am working on files on a remote unRAID NAS (1Gbps network but going to slow things down).

Appreciate the pointers and I hope the above is also useful to others.
rollin_eng
Veteran User
Posts: 4840
Joined: Wed May 04, 2011 11:06 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by rollin_eng »

Try it on a local SSD if you can to remove any disk bottlenecks.
User avatar
s55
HandBrake Team
Posts: 10350
Joined: Sun Dec 24, 2006 1:05 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by s55 »

Normally I'd say try without QSV Decode, but I don't think your CPU has enough grunt to outperform it. It's an unbalanced system for this kind of work.
Network encoding isn't the best of ideas generally. Better to work locally and copy when done.

Are you still running the filter?
DavidIrwin
Posts: 9
Joined: Sun Apr 16, 2017 7:56 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by DavidIrwin »

Thanks for the additional feedback.

I am only enabling the filter when required for individual files. I have something like 20k files to re-encode to standardise formats (and reduce load on my Plex server) as well as hopefully saving some disk space which all appears to be going well.

You are right about the machine. I should not have been so cheap on the CPU but money is fairly tight. Moving to local SSD does improve performance another 20% or so but once again the CPU becomes the limiting factor. I think the Audio transcoding is now my slowest point.

Thanks for the help.
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by mduell »

NVENC is fine for throwaway encodes, but I wouldn't use it for your only archive copy of a video.
DavidIrwin
Posts: 9
Joined: Sun Apr 16, 2017 7:56 pm

Re: NVidia NVENC encoder with Handbrake CLI

Post by DavidIrwin »

mduell wrote: Sun Feb 24, 2019 4:19 pm NVENC is fine for throwaway encodes, but I wouldn't use it for your only archive copy of a video.
Why do you say that? I have been checking many video files whilst doing my testing and not seeing any major discrepancies in quality. It does seem better thatn iQSV on fast moving and not visibily worse that the standard software 264 encoder.

Thanks

David
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: NVidia NVENC encoder with Handbrake CLI

Post by Woodstock »

He probably said it because that's what the manufacturers say about it. Hardware encoders are intended for fast processing of live video streams, so they are not particularly efficient in their encoding, and no particularly good at high quality.

But, quality IS in the eye of the user. If NVENC or QSV is adequate to your eyes, then it is adequate.

I think mduell's point is that you should hang on to the original, if you intended to do anything else with it in the future.
Post Reply