RandomEngy / VidCoder

A Blu-ray, DVD and video file transcoder for Windows.
http://vidcoder.net
GNU General Public License v2.0
687 stars 42 forks source link

NVEnc does not use GPU #699

Open johanbar opened 3 years ago

johanbar commented 3 years ago

Tried a few things to get GPU encoding working but it seems broken, latest clean nVidia driver install, reset Presets. Simply cannot get it to work. Encoding is harsh on a CPU :(

RandomEngy commented 3 years ago

How can you tell that NVEnc is not working? Can you post an encode log? Some filters are not hardware accelerated, so they would work the CPU no matter what.

johanbar commented 3 years ago

In the past with previous versions Vidcoder used to max out 1 of the 2 GPUs in Sli but now only uses CPU. There used to be a Cuba option? NVenc or any other encoder uses no GPU.

Not sure if this log will help, this is a MP4 recoded with only downscaling to 720. The encoder engine is not GPU aware.

VidCoder 6.16 Beta Worker ready: Pipe 'VidCoderWorker.cdf2c6bf-f783-49b1-85a2-f60908ef370f' is open Connecting to process 16904 on pipe VidCoderWorker.cdf2c6bf-f783-49b1-85a2-f60908ef370f [14:38:59] hb_init: starting libhb thread [14:38:59] CPU: Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz [14:38:59] - Intel microarchitecture Sandy Bridge [14:38:59] - logical processor count: 8 [14:38:59] Intel Quick Sync Video support: no [14:38:59] hb_scan: path=C:\Users\johan\Desktop\Junk\Video_20-10-19_00-39-43.mp4, title_index=0 udfread ERROR: ECMA 167 Volume Recognition failed src/libbluray/disc/disc.c:323: failed opening UDF image C:\Users\johan\Desktop\Junk\Video_20-10-19_00-39-43.mp4 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 src/libbluray/bluray.c:2585: nav_get_title_list(C:\Users\johan\Desktop\Junk\Video_20-10-19_00-39-43.mp4) failed [14:38:59] bd: not a bd - trying as a stream/file instead libdvdnav: Using dvdnav version 6.0.1 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 [14:38:59] dvd: not a dvd - trying as a stream/file instead Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\johan\Desktop\Junk\Video_20-10-19_00-39-43.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.42.101 Duration: 01:14:16.49, start: 0.000000, bitrate: 10810 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 3840x2160 [SAR 1:1 DAR 16:9], 10731 kb/s, 21.36 fps, 100 tbr, 90k tbn, 48 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 72 kb/s (default) Metadata: handler_name : SoundHandler [14:38:59] scan: decoding previews for title 1 [14:38:59] scan: audio 0x1: aac, rate=48000Hz, bitrate=72112 Unknown (AAC LC) (2.0 ch) (72 kbps) [14:39:01] scan: 10 previews, 3840x2160, 21.362 fps, autocrop = 0/0/4/4, aspect 16:9, PAR 1:1 [14:39:01] scan: supported video decoders: avcodec qsv [14:39:01] libhb: scan thread found 1 valid title(s)

Hope you can fix this? I notices that the encoder selected is LAV ? Is this correct? Surely NVenc should be used?

image

image

johanbar commented 3 years ago

With Kazaa I've enabled Cuba in LAV hardware support, but this is for decoding only the encoder should be specified by Vidcoder as NVEnc and use hardware accelaration?

Regards Johan

RandomEngy commented 3 years ago

That doesn't look like a full log. Could you make sure you have the encode log selected and put the full log on pastebin? Don't believe there was ever a CUDA option.

johanbar commented 3 years ago

The changes to LAV made no difference. Still CPU only. Verbose log is crazy

RandomEngy commented 3 years ago

I don't need a verbose log. Just a standard log for the encode.

johanbar commented 3 years ago

Hi there

Thanks again for taking a look, if it's any help Handbrake does the same, no GPU acceleration.

Logs: General

VidCoder 6.16 Beta ERROR: Could not cache preview image to C:\Users\johan\AppData\Roaming\VidCoder-Beta\ImageCache\9052\1\1.bmp: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\johan\AppData\Roaming\VidCoder-Beta\ImageCache\9052\1\1.bmp'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at VidCoder.Services.PreviewImageService.BackgroundFileSave(Object state) Starting queue Starting encode: C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59 (Encoded).mp4 Job completed: C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59 (Encoded).mp4 Queue completed

Scan:

VidCoder 6.16 Beta Starting scan: C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4 [09:00:21] CPU: Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz [09:00:21] - Intel microarchitecture Sandy Bridge [09:00:21] - logical processor count: 8 [09:00:21] Intel Quick Sync Video support: no [09:00:21] hb_scan: path=C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4, title_index=0 udfread ERROR: ECMA 167 Volume Recognition failed src/libbluray/disc/disc.c:323: failed opening UDF image C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4 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 src/libbluray/bluray.c:2585: nav_get_title_list(C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4) failed [09:00:21] bd: not a bd - trying as a stream/file instead libdvdnav: Using dvdnav version 6.0.1 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 [09:00:21] dvd: not a dvd - trying as a stream/file instead Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.42.101 Duration: 00:12:08.13, start: 0.000000, bitrate: 9218 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 3840x2160 [SAR 1:1 DAR 16:9], 9143 kb/s, 19.25 fps, 100 tbr, 90k tbn, 48 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 70 kb/s (default) Metadata: handler_name : SoundHandler [09:00:21] scan: decoding previews for title 1 [09:00:21] scan: audio 0x1: aac, rate=48000Hz, bitrate=70656 Unknown (AAC LC) (2.0 ch) (70 kbps) [09:00:23] scan: 10 previews, 3840x2160, 19.253 fps, autocrop = 2/2/0/0, aspect 16:9, PAR 1:1 [09:00:23] scan: supported video decoders: avcodec qsv [09:00:23] libhb: scan thread found 1 valid title(s)

Titles JSON:

{ "MainFeature": 0, "TitleList": [ { "AngleCount": 1, "AudioList": [ { "Attributes": { "AltCommentary": false, "Commentary": false, "Default": true, "Normal": false, "Secondary": false, "VisuallyImpaired": false }, "BitRate": 70656, "ChannelCount": 2, "ChannelLayout": 3, "ChannelLayoutName": "stereo", "Codec": 65536, "CodecName": "aac", "CodecParam": 86018, "Description": "Unknown (AAC LC) (2.0 ch) (70 kbps)", "LFECount": 0, "Language": "Unknown", "LanguageCode": "und", "SampleRate": 48000, "TrackNumber": 1 } ], "ChapterList": [ { "Duration": { "Hours": 0, "Minutes": 12, "Seconds": 8, "Ticks": 65531520 }, "Name": "" } ], "Color": { "Format": 0, "Matrix": 1, "Primary": 1, "Range": 0, "Transfer": 1 }, "Container": "mov,mp4,m4a,3gp,3g2,mj2", "Crop": [ 2, 2, 0, 0 ], "Duration": { "Hours": 0, "Minutes": 12, "Seconds": 8, "Ticks": 65531520 }, "FrameRate": { "Den": 1402415, "Num": 27000000 }, "Geometry": { "Height": 2160, "PAR": { "Den": 1, "Num": 1 }, "Width": 3840 }, "Index": 1, "InterlaceDetected": false, "Metadata": {}, "Name": "Video_20-10-19_19-38-59", "Path": "C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4", "Playlist": -1, "SubtitleList": [], "Type": 3, "VideoCodec": "h264" } ] } Scan completed

Encode log:

VidCoder 6.16 Beta Starting job 1/1 Source path: C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4 Destination path: C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59 (Encoded).mp4 Title: 1 Range: All Preset: Fast 720p25 j2 Worker ready: Pipe 'VidCoderWorker.2d1e7242-531d-466d-bf34-2b32ff038016' is open Connecting to process 10000 on pipe VidCoderWorker.2d1e7242-531d-466d-bf34-2b32ff038016 [09:00:29] hb_init: starting libhb thread [09:00:29] CPU: Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz [09:00:29] - Intel microarchitecture Sandy Bridge [09:00:29] - logical processor count: 8 [09:00:29] Intel Quick Sync Video support: no [09:00:29] hb_scan: path=C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4, title_index=1 udfread ERROR: ECMA 167 Volume Recognition failed src/libbluray/disc/disc.c:323: failed opening UDF image C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4 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 src/libbluray/bluray.c:2585: nav_get_title_list(C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4) failed [09:00:29] bd: not a bd - trying as a stream/file instead libdvdnav: Using dvdnav version 6.0.1 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 [09:00:29] dvd: not a dvd - trying as a stream/file instead Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.42.101 Duration: 00:12:08.13, start: 0.000000, bitrate: 9218 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 3840x2160 [SAR 1:1 DAR 16:9], 9143 kb/s, 19.25 fps, 100 tbr, 90k tbn, 48 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 70 kb/s (default) Metadata: handler_name : SoundHandler [09:00:29] scan: decoding previews for title 1 [09:00:29] scan: audio 0x1: aac, rate=48000Hz, bitrate=70656 Unknown (AAC LC) (2.0 ch) (70 kbps) [09:00:31] scan: 10 previews, 3840x2160, 19.253 fps, autocrop = 2/2/0/0, aspect 16:9, PAR 1:1 [09:00:31] scan: supported video decoders: avcodec qsv [09:00:31] libhb: scan thread found 1 valid title(s) [09:00:31] Starting work at: Tue Oct 20 09:00:31 2020 [09:00:31] 1 job(s) to process [09:00:31] json job: { "Audio": { "AudioList": [ { "Bitrate": 160, "CompressionLevel": 2.0, "DRC": 0.0, "Encoder": "mp3", "Gain": 0.0, "Mixdown": 4, "NormalizeMixLevel": false, "Samplerate": 0, "Track": 0, "DitherMethod": 0 } ], "CopyMask": [ "copy:aac", "copy:ac3", "copy:eac3", "copy:truehd", "copy:dts", "copy:dtshd", "copy:mp3", "copy:flac" ] }, "Destination": { "ChapterList": [ { "Name": "Chapter 1" } ], "ChapterMarkers": true, "AlignAVStart": true, "File": "C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59 (Encoded).part.mp4", "Mp4Options": { "IpodAtom": false, "Mp4Optimize": false }, "Mux": "av_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": 6, "Settings": { "mode": "2", "rate": "27000000/1080000" } }, { "ID": 12, "Settings": { "crop-bottom": "2", "crop-left": "0", "crop-right": "0", "crop-top": "2", "height": "720", "width": "1280" } } ] }, "PAR": { "Num": 540, "Den": 539 }, "Metadata": {}, "SequenceID": 0, "Source": { "Angle": 1, "Range": { "Type": "chapter", "Start": 1, "End": 1 }, "Title": 1, "Path": "C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4" }, "Subtitle": { "Search": { "Burn": false, "Default": false, "Enable": false, "Forced": false }, "SubtitleList": [] }, "Video": { "Encoder": "nvenc_h265", "Level": "3.1", "TwoPass": false, "Turbo": false, "ColorMatrixCode": 0, "Options": "", "Preset": "fast", "Profile": "main", "Quality": 22.0, "QSV": { "Decode": false, "AsyncDepth": 0 } } } [09:00:31] Starting Task: Encoding Pass [09:00:31] work: track 1, dithering not supported by codec [09:00:31] work: only 1 chapter, disabling chapter markers [09:00:31] job configuration: [09:00:31] source [09:00:31] + C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59.mp4 [09:00:31] + title 1, chapter(s) 1 to 1 [09:00:31] + container: mov,mp4,m4a,3gp,3g2,mj2 [09:00:31] + data rate: 9218 kbps [09:00:31] destination [09:00:31] + C:\Users\johan\Desktop\Junk\Video_20-10-19_19-38-59 (Encoded).part.mp4 [09:00:31] + container: MPEG-4 (libavformat) [09:00:31] + align initial A/V stream timestamps [09:00:31] video track [09:00:31] + decoder: h264 [09:00:31] + bitrate 9143 kbps [09:00:31] + filters [09:00:31] + 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) [09:00:31] + Decomb (mode=39) [09:00:31] + Framerate Shaper (mode=2:rate=27000000/1080000) [09:00:31] + frame rate: 19.253 fps -> peak rate limited to 25.000 fps [09:00:31] + Crop and Scale (width=1280:height=720:crop-top=2:crop-bottom=2:crop-left=0:crop-right=0) [09:00:31] + source: 3840 2160, crop (2/2/0/0): 3840 2156, scale: 1280 720 [09:00:31] + Output geometry [09:00:31] + storage dimensions: 1280 x 720 [09:00:31] + pixel aspect ratio: 540 : 539 [09:00:31] + display dimensions: 1282 x 720 [09:00:31] + encoder: H.265 (NVEnc) [09:00:31] + preset: fast [09:00:31] + profile: main [09:00:31] + level: 3.1 [09:00:31] + quality: 22.00 (CQ) [09:00:31] + color profile: 1-1-1 [09:00:31] * audio track 1 [09:00:31] + decoder: Unknown (AAC LC) (2.0 ch) (70 kbps) (track 1, id 0x1) [09:00:31] + bitrate: 70 kbps, samplerate: 48000 Hz [09:00:31] + mixdown: Stereo [09:00:31] + encoder: MP3 (libmp3lame) [09:00:31] + bitrate: 160 kbps, samplerate: 48000 Hz [09:00:31] + compression level: 2.00 [09:00:31] sync: expecting 14018 video frames [09:00:31] encavcodecInit: H.265 (Nvidia NVENC) [09:00:31] encavcodec: truncating framerate 5400000 / 280483 [09:00:31] encavcodec: encoding at rc=vbr_hq 22.00 [09:00:31] encavcodec: encoding with stored aspect 540/539 [09:00:32] sync: first pts video is 0 [09:00:32] sync: "Chapter 1" (1) at frame 1 time 0 [09:00:32] sync: first pts audio 0x1 is 0 [09:08:58] reader: done. 1 scr changes [09:09:01] work: average encoding speed for job is 27.589411 fps [09:09:01] comb detect: heavy 25 | light 357 | uncombed 13636 | total 14018 [09:09:01] decomb: deinterlaced 25 | blended 357 | unfiltered 13636 | total 14018 [09:09:01] vfr: 14018 frames output, 0 dropped and 0 duped for CFR/PFR [09:09:01] vfr: lost time: 0 (0 frames) [09:09:01] vfr: gained time: 0 (0 frames) (0 not accounted for) [09:09:01] aac-decoder done: 34129 frames, 0 decoder errors [09:09:01] h264-decoder done: 14018 frames, 0 decoder errors [09:09:01] sync: got 14018 frames, 14018 expected [09:09:01] sync: framerate min 1.852 fps, max 33.333 fps, avg 19.253 fps [09:09:01] mux: track 0, 14018 frames, 253024795 bytes, 2780.06 kbps, fifo 1024 [09:09:01] mux: track 1, 30337 frames, 14561760 bytes, 159.99 kbps, fifo 4096 [09:09:01] Finished work at: Tue Oct 20 09:09:01 2020 [09:09:01] libhb: work result = 0 Job completed (Elapsed Time: 8m 34s)

System Win Server 2019, 2 x GPU 1070s in SLI

Thanks again for helping :)

johanbar commented 3 years ago

No luck with the gpu problem I guess?

RandomEngy commented 3 years ago

I have a full time job and a family. This is on my list of things to take a look at when I have spare time.

sr55 commented 3 years ago

NVEnc is encode only. Everything else is run on the CPU and if the CPU is too slow to feed the Nvidia card, then the nvidia card will run slow.

Your CPU is far too slow to run the video decoding, filters, audio, sync/pipeline for 4K content without bottlenecking that card.

I'm not sure if you have mixed content where some of your source is interlaced but if you know fore sure it's not interlaced, I'd turn off decomb/interlace detection for a modest speed up. Ultimately though, you'll struggle to get anywhere near full utilisation with the CPU in that system bottlenecking it.

Also, for your information, SLI is irrelevant to NVEnc.

johanbar commented 3 years ago

CPU is overlocked to 4.3 GHz boosts to 5.2 GHz. No GPU encoding at 4K.

johanbar commented 3 years ago

image

Liquid cooled system with custom compiled bios ....

sr55 commented 3 years ago

Overclocked Clockspeeds and liquid cooling here are irrelevant. It's still an old CPU architecture, only 4 cores and slow memory attached to it. It's not fast enough to decode 4K, filter that 4K content, encode audio and manage the rest of the pipeline before hand-off to nvenc for encoding. NVenc is spending the majority of the time waiting on the CPU here.

It's just a limitation of your hardware at play.

As I already said, if you don't need filters, turn them off as it'll take a fair bit of the load off the CPU and free it up to decode frames a bit faster.

johanbar commented 3 years ago

Thank you for your contribution

johanbar commented 3 years ago

The reason Vidcoder does not use GPU I suspect is because the input decoder is likely not specified to use GPU. I do encoding manually now with:

"C:\ProgramData\chocolatey\lib\ffmpeg\tools\ffmpeg\bin\ffmpeg.exe" -hide_banner -hwaccel d3d11va -y -i "%%f" -map_metadata -1 -vcodec hevc_nvenc -gpu 0 -rc vbr -cq 24 -qmin 24 -qmax 24 -profile:v main10 -acodec copy -bsf:a aac_adtstoasc -f mp4 "enc\%%f"

This uses -hwaccel d3d11va (I think Qvid is quite old but also works). Keeps the fps and dimensions and saves 20-50% without quality loss.

Would be nice to be able to specify this.

Also run a parallel process with -gpu 1 to use the second GPU. This encodes 2 files each using a GPU. Would be nice if Vidcoder can balance like this.

CPU around 10% for each and GPUs running at about 70% each, so little system impact.

Regards