協助理解 Handbrake 與 NVidia 的整合

不幸的是,似乎我遇到了一次轉檔失敗(在多次成功之後),我在這裡有點難以追蹤到底發生了什麼,非常感謝任何協助我釐清此事的幫助。

從我能看到的來說,NVidia 硬體查詢是通過的(耶):

--> Checking presence and capabilities of NVidia NVENC Hardware encoder
2019-11-16T17:18:04 MCEBuddy.AppWrapper.NVidiaQuery --> Launching process C:\Program Files\MCEBuddy2x\nvidia\nvidiaQuery.exe
2019-11-16T17:18:04 MCEBuddy.AppWrapper.NVidiaQuery --> Process arguments 
2019-11-16T17:18:04 MCEBuddy.AppWrapper.NVidiaQuery --> UI Session Admin Process : True
2019-11-16T17:18:04 MCEBuddy.AppWrapper.NVidiaQuery --> Starting process as a UISession process with Admin privileges. This requires atleast 1 user to be logged into the system (remote desktop or locally)
2019-11-16T17:18:04 MCEBuddy.AppWrapper.NVidiaQuery --> Setting process priority to Normal
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery --> C:\Program Files\MCEBuddy2x\nvidia\nvidiaQuery.exe Starting...
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->  CUDA Device Query (Runtime API) version (CUDART static linking)
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery --> Detected 1 CUDA Capable device(s)
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery --> Device 0: "GeForce GTX 1050"
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   CUDA Driver Version / Runtime Version          10.1 / 7.5
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery --> Detected CUDA Driver version = 10.1
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   CUDA Capability Major/Minor version number:    6.1
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery --> Detected CUDA Hardware version = 6.1
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Total amount of global memory:                 2048 MBytes (2147483648 bytes)
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery --> MapSMtoCores for SM 6.1 is undefined.  Default to use 128 Cores/SM
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery --> MapSMtoCores for SM 6.1 is undefined.  Default to use 128 Cores/SM
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   ( 5) Multiprocessors, (128) CUDA Cores/MP:     640 CUDA Cores
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   GPU Max Clock rate:                            1519 MHz (1.52 GHz)
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Memory Clock rate:                             3504 Mhz
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Memory Bus Width:                              128-bit
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   L2 Cache Size:                                 1048576 bytes
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Total amount of constant memory:               65536 bytes
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Total amount of shared memory per block:       49152 bytes
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Total number of registers available per block: 65536
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Warp size:                                     32
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Maximum number of threads per multiprocessor:  2048
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Maximum number of threads per block:           1024
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Maximum memory pitch:                          2147483647 bytes
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Texture alignment:                             512 bytes
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Run time limit on kernels:                     Yes
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Integrated GPU sharing Host Memory:            No
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Support host page-locked memory mapping:       Yes
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Alignment requirement for Surfaces:            Yes
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Device has ECC support:                        Disabled
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   CUDA Device Driver Mode (TCC or WDDM):         WDDM (Windows Display Driver Model)
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Device supports Unified Addressing (UVA):      Yes
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->   Compute Mode:
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery -->      < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery --> deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.1, CUDA Runtime Version = 7.5, NumDevs = 1, Device0 = GeForce GTX 1050
2019-11-16T17:18:05 MCEBuddy.AppWrapper.NVidiaQuery --> Result = PASS

但接著似乎又說找不到硬體(噓):

2019-11-16T17:18:09 MCEBuddy.Transcode.ConvertWithHandbrake --> Cannot find supported h264/h265 software/hardware encoder combination in profile, disabling auto hardware encoder adjustments

然後似乎就切換到軟體模式並在這之後失敗:

INFORMATION> 2019-11-16T17:18:09 MCEBuddy.Transcode.Convert --> Converting with Handbrake, type: SoftwareOnly, gpu: {
  "hardwareBrand": "Any",
  "codecType": "Undefined",
  "hardwareCodecPresent": false,
  "h265Codec": false,
  "h264Codec": false
}

我唯一能想到的是,當時 Plex Transcoder.exe 正在執行……這會是問題嗎?我一直以為 GPU 可以像 CPU 一樣同時被多個應用程式使用。我在想是否有其他設定我應該考慮。

如往常一樣,非常感謝任何人能提供的時間與協助。附上完整紀錄。

College Football (2009) - S2019E2580 - Michigan State at Michigan.ts-Default-2019-11-16T17-05-29.9420785-05-00.log (1.4 MB)

更多参考/背景信息如下。我能够在流式传输/转码进行的同时录制另一场游戏,因此这似乎并非由于GPU被占用导致的。

也可能是Plex相关的问题。毕竟它还处于beta模式。:laughing:

實際上它偵測到了你的 Nvidia 編碼器,但你的設定檔無效,因此會停用所有自動調整。

如果你的設定檔 handbrake-video 包含 encoder nvenc_h264,也就是說你的設定檔已經設定為使用硬體編碼器。MCEBuddy 正在尋找軟體編碼器 x264,以便自動啟用其硬體調整功能,或是在你的設定檔中尋找 handbrake-UsingHardwareEncoding=true 指令,該指令會告訴 MCEBuddy 該設定檔已針對硬體編碼進行最佳化,不應進行任何變更,只需執行它,因此最終導致設定檔無效。

請在設定檔中將編碼器切換為軟體編碼器,或加入 handbrake-UsingHardwareEncoding=true 指令。

好的!太棒了……谢谢你 @RBoy,一如既往地非常感谢你的帮助。:blush:

我唯一的问题是……它为什么要寻找(或尝试切换到)软件编码?看起来它一直使用的是硬件编码,但也许是我理解错了。

顺便说一下,我的配置文件现在是这样的:

[Handbrake Cli 1.2.0 H265 - Quality 25]
Description=nVidia NVENC HW (H265) Quality Setting 25 + Decomb
order=handbrake
FixedResolution=true
handbrake-general=--loose-anamorphic --comb-detect=fast --decomb=mode=7 --verbose=2 --format av_mp4 --subtitle-lang-list eng,spa --all-subtitles --subtitle-default=1 --native-language eng --native-dub
handbrake-video=--start-at duration:0 --encoder nvenc_h264 --encoder-preset slow --quality 25 --vfr
handbrake-audio=--aencoder copy:aac --audio-lang-list eng --all-audio
handbrake-audioac3=--aencoder copy:ac3 --audio-lang-list eng --all-audio
handbrake-ext=.m4v
handbrake-audiodelay=skip
handbrake-UsingHardwareEncoding=true
PreConversionCommercialRemover=true

看看这次效果如何。:+1:

(顺便说一句,我知道它叫 H265,但实际上找的是 h264——我一直忘了改!:laughing:

它不会默认改为软件编码,所有随 MCEBuddy 提供的配置文件默认都只使用软件编码器。程序会检测显卡,如果支持,则在运行时切换为硬件编码器。如果你正在创建一个针对硬件编码优化的自定义配置文件,就需要让 MCEBuddy 知道现在开始查找。

我们将来会改变这一点:如果 MCEBuddy 检测到配置文件包含硬件编码器,它会自动设置硬件优化标志 <encoder>-UsingHardwareEncoding=true

很不幸,在按上述配置之后,我仍然遇到间歇性问题。请见附件。

看起来 Handbrake 以非零返回码失败,因此问题似乎出在 Handbrake 这边。

我会向 Handbrake 提交 issue,但在此之前想先在这里确认,确保没有其他 MCEBuddy 设置需要调整。

日志已附在此处:NFL Football - S2019E2191 - Chicago Bears at Detroit Lions.ts-Football-2019-11-28T16-35-04.5332992-05-00.log(1.3 MB)

看起來您的

該死……原來是這樣。:laughing: 我的顯示卡有 2GB 記憶體,而且這問題是間歇性的,只偶爾發生。

顯示卡驅動程式有點舊,所以我已經更新過了。除了換一張更大的顯示卡,大概也沒別的辦法了。

感謝你的協助,@RBoy:+1:

这个错误来自显卡驱动,很可能是软件内存泄漏而不是硬件问题。

好的,謝謝你 @RBoy……我們來看看最新版本是否解決了這個問題,如果沒有,我想可能是 Plex 本身導致的。:downcast_face_with_sweat:

如果您使用超过 2 个并发转换,NVIDIA 显卡驱动程序将不允许,因为它们有 2 个同时转码的硬性限制,详见此帖:

啊……我打賭就是這麼回事!我們家現在有 3 台 Roku,以前還沒裝 GPU 時,只要一個轉碼串流就會吃掉 50–85% 的 CPU。

所以我乾脆把所有串流都設成「原始」,這樣就不會觸發轉碼。

不過裝了 GPU 之後才發現,跑轉碼串流根本小菜一碟(本來就該這樣):CPU 只佔 5–10%。實際上兩個同時串流也大約 15%。

我還沒試過 3 台 Roku 同時串流,但要是後製還得再轉一次碼,就會落入你說的那種情境。真是個限制 :stuck_out_tongue:

我得再好好盤算要怎麼處理……感謝你提供的額外資訊與脈絡。:+1: