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

Neither CUDA nor NVDEC will enable on Windows #5978

Closed
Doofussy2 opened this issue Jul 8, 2018 · 67 comments
Closed

Neither CUDA nor NVDEC will enable on Windows #5978

Doofussy2 opened this issue Jul 8, 2018 · 67 comments

Comments

@Doofussy2
Copy link

Doofussy2 commented Jul 8, 2018

Latest Git build, but it's been this way for as long as I've had my GTX 1050 (a few months)
Windows 10

Reproduction steps
Using hwdec=cuda or hwdec=nvdec in the mpv.conf, results in software decoding. But cuda-copy and nvdec-copy, work

Expected behavior
Hardware decoding

Portable mpv log.txt

I've also reported this Nvidia, in case it's a driver issue.

@morphological
Copy link

morphological commented Jul 10, 2018

Encoding works fine when ffmpeg is compiled with --enable-nvenc and --enable-cuvid
Gotta install the headers first though: lutris/ffmpeg-nvenc#22
Guide over here: https://github.com/mpv-player/mpv-build

  --ovc=h264_nvenc   NVIDIA NVENC H.264 encoder
  --ovc=nvenc        NVIDIA NVENC H.264 encoder
  --ovc=nvenc_h264   NVIDIA NVENC H.264 encoder
  --ovc=nvenc_hevc   NVIDIA NVENC hevc encoder
  --ovc=hevc_nvenc   NVIDIA NVENC hevc encoder

Decoding with nvenc also works btw, you just need to install the SDK.

@Doofussy2
Copy link
Author

Thanks for responding, but this is confusing. First, I'm not encoding anything. Second, the mpv manual says to use hwdec=cuda with vo=gpu. This is the method used for all hwdec, in the manual. It works with other decoders but not cuda or nvdec. Has something changed that hasn't been updated in the manual?

@aufkrawall
Copy link

cuda & nvdec only work with --gpu-api=opengl

@Doofussy2
Copy link
Author

I believe I tried that, with no success. I will retest, when I get a chance.

Thank you.

@Doofussy2
Copy link
Author

Just tested with gpu-api=opengl with cuda and nvdec. No change. They will not enable. Other guys I've talked to online, also can't get them to enable.

@aufkrawall
Copy link

You're right, doesn't work here either with @shinchiro 's build while it works with self compiled build on Linux.

@Doofussy2
Copy link
Author

Still not working in the 2018-07-14 build

@saildata
Copy link

saildata commented Jul 14, 2018

Works here. https://i.imgur.com/bOWgOJb.jpg

OS: Arch Linux 4.17.5, 1080-Ti 11G

  • Installed ffnvcodec-headers as others have mentioned.
  • Added --enable-nvenc to ffmpeg build options.

mpv --version

mpv 0.28.0-633-g351c083487 Copyright © 2000-2018 mpv/MPlayer/mplayer2 projects
 built on UNKNOWN
ffmpeg library versions:
   libavutil       56.18.102
   libavcodec      58.21.105
   libavformat     58.17.101
   libswscale      5.2.100
   libavfilter     7.25.100
   libswresample   3.2.100
ffmpeg version: N-91473-gc5329d64b1

MPV stdout:

(+) Video --vid=1 (*) (vp9 3840x2160 60.000fps)
 (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
Using hardware decoding (nvdec).
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 3840x2160 cuda[nv12]

I also have vo=gpu hwdec=auto gpu-api=auto
it was not necessary to have gpu-api=opengl for mine. Just for fun, I ran the same video in 'benchmark' mode:

[bench]
hwdec=cuda
scale=ewa_lanczossharp
cscale=ewa_lanczossharp
vd-lavc-threads=32
audio=no
untimed=yes
video-sync=display-desync
vulkan-swap-mode=immediate
opengl-swapinterval=0
opengl-pbo
osd-msg1="FPS: ${estimated-display-fps}"

and got around 250fps on 3840*2160 UHD. All seems to be fine on this end. I think it just depends on your build and having the right libraries installed.
https://i.imgur.com/YIaezFe.jpg

@shinchiro
Copy link
Contributor

Uh, I'll explicitly add --enable-nvdec when configuring ffmpeg if that will change anything. It's supposed to be on (autodetect) by default before.

@saildata
Copy link

I think I also used --enable-cuvid or --enable-cuda I can't remember which. Sorry I built in /tmp and deleted my makefiles.

@Doofussy2
Copy link
Author

@shinchiro , unfortunately, cuda nor nvdec are still not enabling in your latest build :(

@shinchiro
Copy link
Contributor

[vo/gpu] Loading hwdec driver 'cuda-nvdec'
Cannot load cuInit
[vo/gpu/cuda-nvdec] Failed to load CUDA symbols
[vo/gpu] Loading failed.
[vd] Could not create device.

Just realized, it's always enable before. I believe you need to download/install cuda toolkit (~1.5GB) to use it.

@Doofussy2
Copy link
Author

Doofussy2 commented Jul 21, 2018

So to use nvdec or cuda, the cuda toolkit needs to be installed? The manual needs to be amended, to inform the user to do this. As is, the manual states that you can simply enable it.

https://mpv.io/manual/stable/#options-hwdec

cuda: requires --vo=gpu (Any platform CUDA is available)
nvdec: requires --vo=gpu (Any platform CUDA is available)

@Doofussy2
Copy link
Author

@shinchiro . I installed it, no change. It still doesn't enable.

@aufkrawall
Copy link

I don't think that something cuda/nvdec related is missing, as -copy modes work. It rather seems to me that something interop related doesn't work with Windows builds.

@Doofussy2
Copy link
Author

This is what I see in the log

[ 0.233][v][vd] Codec list:
[ 0.233][v][vd] hevc - HEVC (High Efficiency Video Coding)
[ 0.233][v][vd] hevc_cuvid (hevc) - Nvidia CUVID HEVC decoder
[ 0.233][v][vd] Opening decoder hevc
[ 0.234][v][vd] Looking at hwdec hevc-nvdec...
[ 0.234][v][vo/gpu] Loading hwdec driver 'd3d11-egl'
[ 0.235][v][vo/gpu] Loading failed.
[ 0.235][v][vo/gpu] Loading hwdec driver 'd3d11-egl-rgb'
[ 0.235][v][vo/gpu] Loading failed.
[ 0.235][v][vo/gpu] Loading hwdec driver 'dxva2-egl'
[ 0.235][v][vo/gpu] Loading failed.
[ 0.235][v][vo/gpu] Loading hwdec driver 'd3d11va'
[ 0.240][v][vo/gpu] Loading hwdec driver 'dxva2-dxgi'
[ 0.338][v][vo/gpu] Loading hwdec driver 'dxva2-dxinterop'
[ 0.338][v][vo/gpu] Loading failed.
[ 0.338][v][vo/gpu] Loading hwdec driver 'cuda-nvdec'
[ 0.338][v][vo/gpu] Loading failed.
[ 0.338][v][vd] Could not create device.
[ 0.338][v][vd] No hardware decoding available for this codec.
[ 0.338][v][vd] Using software decoding.

@Doofussy2
Copy link
Author

It isn't enabling in 0.29, either

@g3r
Copy link

g3r commented Jul 25, 2018

This is not a Windows only problem. I have the same problem in archlinux, reverted to 0.28 where it works fine.

@aufkrawall
Copy link

Weird that the Arch repo build is affected, it works here with this adjusted pkgbuild of mpv-build-git:
https://pastebin.com/1jQ20ucW

@Doofussy2
Copy link
Author

Not to be a pain, but is there any development on on this? Is this an OS issue?

@tomty89
Copy link
Contributor

tomty89 commented Jul 27, 2018

@Doofussy2 Maybe you can set the message level to trace to see at which function it failed exactly:

MP_TRACE(hw, "Calling %s\n", func);

@Doofussy2
Copy link
Author

Doofussy2 commented Jul 27, 2018

Thanks @tomty89 I'm going to add --msg-level=all=trace to the mpv.conf, then post the log

UPDATE:
That log is 76 MB.

@tomty89
Copy link
Contributor

tomty89 commented Jul 27, 2018

@Doofussy2 --msg-level=vo/gpu=trace

@Doofussy2
Copy link
Author

Doofussy2 commented Jul 27, 2018

Thanks @tomty89. Here's the log with that, using @shinchiro's build, trying to use hwdec=cuda

Portable mpv log.txt

@tomty89
Copy link
Contributor

tomty89 commented Jul 27, 2018

Somehow the message level was not increased in this part:

[   0.169][v][vd] Looking at hwdec hevc_cuvid-cuda...
[   0.169][v][vo/gpu] Loading hwdec driver 'd3d11-egl'
[   0.169][v][vo/gpu] Loading failed.
[   0.169][v][vo/gpu] Loading hwdec driver 'd3d11-egl-rgb'
[   0.169][v][vo/gpu] Loading failed.
[   0.169][v][vo/gpu] Loading hwdec driver 'dxva2-egl'
[   0.169][v][vo/gpu] Loading failed.
[   0.169][v][vo/gpu] Loading hwdec driver 'd3d11va'
[   0.170][v][vo/gpu] Loading hwdec driver 'dxva2-dxgi'
[   0.216][v][vo/gpu] Loading hwdec driver 'dxva2-dxinterop'
[   0.216][v][vo/gpu] Loading failed.
[   0.216][v][vo/gpu] Loading hwdec driver 'cuda-nvdec'
[   0.216][v][vo/gpu] Loading failed.
[   0.216][v][vd] Could not create device.

Maybe we need --msg-level=vd=trace instead? Not really sure how --msg-level works to be honest.

@Doofussy2
Copy link
Author

That appears to be giving the same output, but here it is

Portable mpv log.txt

@tomty89
Copy link
Contributor

tomty89 commented Jul 27, 2018

Hmm what about --msg-level=vo/cuda-nvdec=strace or --msg-level=vo=strace?

@Doofussy2
Copy link
Author

Doofussy2 commented Jul 27, 2018

I think what is probably required, is this --msg-level=vo/gpu=trace. Which makes this log. I'm not sure it provides any more info, though.

Portable mpv log.txt

@sc44
Copy link

sc44 commented Jul 28, 2018

Hello,
i am using Arch too. I have recompiled mpv 0.29 on my System with the community PKGBUILD.
Now it runs. I'm not sure if that's important, i use my own ffmpeg version.
https://pastebin.com/20Bj5Z3D
https://pastebin.com/SpGrBSXC
Edit.: I have now recompiled and tested it with the ffmpeg of extra, runs as well.

@Doofussy2
Copy link
Author

Doofussy2 commented Aug 1, 2018

Is there anything else I can provide, to help? @lachs0r?

@aufkrawall
Copy link

It's btw. fixed with latest repo build on Arch.

@prowal
Copy link

prowal commented Oct 16, 2018

I did some research and can't find any windows build with nvdec or cuda actually working (recent or past @lachs0r or @shinchiro builds)

In recent builds, the issue doesn't seem to be the same:

@lachs0r:
[vd] Codec list:
[vd] hevc - HEVC (High Efficiency Video Coding)
[vd] hevc_cuvid (hevc) - Nvidia CUVID HEVC decoder
[vd] Opening decoder hevc
[vd] Looking at hwdec hevc_cuvid-cuda...
[vo/gpu] Loading hwdec driver 'd3d11va'
[vo/gpu] Loading hwdec driver 'dxva2-dxgi'
[vo/gpu] Loading hwdec driver 'dxva2-dxinterop'
[vo/gpu] Loading failed.
[vd] Could not create device.
[vd] No hardware decoding available for this codec.
[vd] Using software decoding.

@shinchiro:

[vd] Codec list:
[vd] hevc - HEVC (High Efficiency Video Coding)
[vd] hevc_cuvid (hevc) - Nvidia CUVID HEVC decoder
[vd] Opening decoder hevc
[vd] Looking at hwdec hevc_cuvid-cuda...
[vo/gpu] Loading hwdec driver 'd3d11-egl'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'd3d11-egl-rgb'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'dxva2-egl'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'd3d11va'
[vo/gpu] Loading hwdec driver 'dxva2-dxgi'
[vo/gpu] Loading hwdec driver 'dxva2-dxinterop'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'cuda-nvdec'
[vo/gpu] Loading failed.
[vd] Could not create device.
[vd] No hardware decoding available for this codec.
[vd] Using software decoding.

@philipl
Copy link
Member

philipl commented Oct 16, 2018

Those lines say that @lachs0r build doesn't have the cuda hwdec built into it but the @shinchiro ones does. So you need to focus on the @shinchiro one.

You need to turn the logging all the way up to TRACE and see what else it says when it tries to load it. I would expect it's saying it can't find the right dlls. Please grab the additional logs and add them here.

@prowal
Copy link

prowal commented Oct 16, 2018

there isn't more information with --msg-level=all=trace:
[vd] Codec list:
[vd] hevc - HEVC (High Efficiency Video Coding)
[vd] hevc_cuvid (hevc) - Nvidia CUVID HEVC decoder
[vd] Opening decoder hevc
[vd] Looking at hwdec hevc_cuvid-cuda...
[vo/gpu] Loading hwdec driver 'd3d11-egl'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'd3d11-egl-rgb'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'dxva2-egl'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'd3d11va'
[vo/gpu] Loading hwdec driver 'dxva2-dxgi'
[vo/gpu] Loading hwdec driver 'dxva2-dxinterop'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'cuda-nvdec'
[vo/gpu] Loading failed.
[vd] Could not create device.
[vd] No hardware decoding available for this codec.
[vd] Using software decoding.

BUT: i realized that hwdecode is actually working with --hwdec=auto:
[vd] Codec list:
[vd] hevc - HEVC (High Efficiency Video Coding)
[vd] hevc_cuvid (hevc) - Nvidia CUVID HEVC decoder
[vd] Opening decoder hevc
[vd] Looking at hwdec hevc-d3d11va...
[vo/gpu] Loading hwdec driver 'd3d11-egl'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'd3d11-egl-rgb'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'dxva2-egl'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'd3d11va'
[vo/gpu] Loading hwdec driver 'dxva2-dxgi'
[vo/gpu] Loading hwdec driver 'dxva2-dxinterop'
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'cuda-nvdec'
[vo/gpu] Loading failed.
[vd] Trying hardware decoding via hevc-d3d11va.
[ffmpeg/video] hevc: Invalid default display window
[vd] Selected codec: hevc (HEVC (High Efficiency Video Coding))

@Doofussy2
Copy link
Author

I've tried trace logs in previous posts, but it doesn't reveal any more information. Is there a specific expression to expand the GPU logging?

@philipl
Copy link
Member

philipl commented Oct 16, 2018

@prowal Yeah, in the auto case it's using d3d11va, which is a perfectly reasonable choice.

When you guys say you used trace logging, I really expect to see other stuff. There should be some lines from the cuda hwdec after it says "Loading hwdec driver 'cuda-nvdec'. I see these on linux.

@Doofussy2
Copy link
Author

Doofussy2 commented Oct 16, 2018

Is it not generating more because it isn't being enabled, or is it actually the logging that needs augmenting?

The log does say it's trying to load cuda-nvdec, but it shows it failing. But no logging to indicate why.

[vo/gpu] Loading hwdec driver 'cuda-nvdec'
[vo/gpu] Loading failed.

@philipl
Copy link
Member

philipl commented Oct 17, 2018

So, on my linux system where this works, I see:

[vo/gpu] Loading hwdec driver 'cuda-nvdec'
[vo/gpu/cuda-nvdec] Calling cu->cuInit(0)
[vo/gpu/cuda-nvdec] Calling cu->cuGLGetDevices(&device_count, &display_dev, 1, CU_GL_DEVICE_LIST_ALL)
[vo/gpu/cuda-nvdec] Calling cu->cuCtxCreate(&p->display_ctx, CU_CTX_SCHED_BLOCKING_SYNC, display_dev)
[ffmpeg] AVHWDeviceContext: Loaded lib: libcuda.so.1
[ffmpeg] AVHWDeviceContext: Loaded sym: cuInit
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDeviceGetCount
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDeviceGet
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDeviceGetName
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDeviceGetUuid
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDeviceComputeCapability
[ffmpeg] AVHWDeviceContext: Loaded sym: cuCtxCreate_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuCtxSetLimit
[ffmpeg] AVHWDeviceContext: Loaded sym: cuCtxPushCurrent_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuCtxPopCurrent_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuCtxDestroy_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuMemAlloc_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuMemFree_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuMemcpy2D_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuMemcpy2DAsync_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGetErrorName
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGetErrorString
[ffmpeg] AVHWDeviceContext: Loaded sym: cuStreamCreate
[ffmpeg] AVHWDeviceContext: Loaded sym: cuStreamQuery
[ffmpeg] AVHWDeviceContext: Loaded sym: cuStreamSynchronize
[ffmpeg] AVHWDeviceContext: Loaded sym: cuStreamDestroy_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuStreamAddCallback
[ffmpeg] AVHWDeviceContext: Loaded sym: cuEventCreate
[ffmpeg] AVHWDeviceContext: Loaded sym: cuEventDestroy_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuEventSynchronize
[ffmpeg] AVHWDeviceContext: Loaded sym: cuEventQuery
[ffmpeg] AVHWDeviceContext: Loaded sym: cuEventRecord
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGLGetDevices_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGraphicsGLRegisterImage
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGraphicsUnregisterResource
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGraphicsMapResources
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGraphicsUnmapResources
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGraphicsSubResourceGetMappedArray
[ffmpeg] AVHWDeviceContext: Loaded sym: cuImportExternalMemory
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDestroyExternalMemory
[ffmpeg] AVHWDeviceContext: Loaded sym: cuExternalMemoryGetMappedBuffer
[ffmpeg] AVHWDeviceContext: Loaded sym: cuExternalMemoryGetMappedMipmappedArray
[ffmpeg] AVHWDeviceContext: Loaded sym: cuMipmappedArrayGetLevel
[ffmpeg] AVHWDeviceContext: Loaded sym: cuImportExternalSemaphore
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDestroyExternalSemaphore
[ffmpeg] AVHWDeviceContext: Loaded sym: cuSignalExternalSemaphoresAsync
[vo/gpu/cuda-nvdec] Calling cu->cuCtxPopCurrent(&dummy)

The ways it can fail before Calling cu->cuInit(0) line generate verbose logging, which you should see. This is odd.

@Doofussy2
Copy link
Author

Interesting. Maybe Linux has more tools to be able to analyze more thoroughly?

@shinchiro
Copy link
Contributor

@philipl on my windows system, it failed at

MP_VERBOSE(hw, "Failed to load CUDA symbols\n");

so the CHECK_CU function never called in the first place. Of course, the dlls is there as ffmpeg can find it

@shinchiro
Copy link
Contributor

shinchiro commented Oct 17, 2018

Here's the extracted symbols found in nvcuda.dll (version, 398.36): https://0x0.st/sELa.txt

I did compared the symbols with the one in nv-codec-headers and some of the symbols do not exist in the dll. Probably that's fault, I guess?

Here's the symbols lines which absent in the dll
https://github.com/FFmpeg/nv-codec-headers/blob/d098cb44f6103a03476d16ac2bbe14ecbc9e1175/include/ffnvcodec/dynlink_loader.h#L175-L178

@philipl
Copy link
Member

philipl commented Oct 17, 2018

The symbols that don't exist in the dll are loaded using LOAD_SYMBOL_OPT so they should not cause a loading failure. @shinchiro, you have built ffmpeg with the same headers version right? If the 'nvdec-copy' hwdec loads successfully, that means ffmpeg was able to load the symbols, but you really should see the same success or failure.

Can you try that?

@shinchiro
Copy link
Contributor

yeah, nvdec-copy works

[vd] Codec list:
[vd]     h264 - H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
[vd]     h264_cuvid (h264) - Nvidia CUVID H264 decoder
[vd] Opening decoder h264
[vd] Looking at hwdec h264-nvdec-copy...
[ffmpeg] AVHWDeviceContext: Loaded lib: nvcuda.dll
[ffmpeg] AVHWDeviceContext: Loaded sym: cuInit
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDeviceGetCount
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDeviceGet
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDeviceGetName
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDeviceGetUuid
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDeviceComputeCapability
[ffmpeg] AVHWDeviceContext: Loaded sym: cuCtxCreate_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuCtxSetLimit
[ffmpeg] AVHWDeviceContext: Loaded sym: cuCtxPushCurrent_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuCtxPopCurrent_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuCtxDestroy_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuMemAlloc_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuMemFree_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuMemcpy2D_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuMemcpy2DAsync_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGetErrorName
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGetErrorString
[ffmpeg] AVHWDeviceContext: Loaded sym: cuStreamCreate
[ffmpeg] AVHWDeviceContext: Loaded sym: cuStreamQuery
[ffmpeg] AVHWDeviceContext: Loaded sym: cuStreamSynchronize
[ffmpeg] AVHWDeviceContext: Loaded sym: cuStreamDestroy_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuStreamAddCallback
[ffmpeg] AVHWDeviceContext: Loaded sym: cuEventCreate
[ffmpeg] AVHWDeviceContext: Loaded sym: cuEventDestroy_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuEventSynchronize
[ffmpeg] AVHWDeviceContext: Loaded sym: cuEventQuery
[ffmpeg] AVHWDeviceContext: Loaded sym: cuEventRecord
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGLGetDevices_v2
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGraphicsGLRegisterImage
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGraphicsUnregisterResource
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGraphicsMapResources
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGraphicsUnmapResources
[ffmpeg] AVHWDeviceContext: Loaded sym: cuGraphicsSubResourceGetMappedArray
[ffmpeg] AVHWDeviceContext: Loaded sym: cuImportExternalMemory
[ffmpeg] AVHWDeviceContext: Loaded sym: cuDestroyExternalMemory
[ffmpeg] AVHWDeviceContext: Loaded sym: cuExternalMemoryGetMappedBuffer
[ffmpeg] AVHWDeviceContext: Loaded sym: cuExternalMemoryGetMappedMipmappedArray
[ffmpeg] AVHWDeviceContext: Loaded sym: cuMipmappedArrayGetLevel
[vd] Trying hardware decoding via h264-nvdec-copy.

The error before came from hwdec nvdec or cuda (without copy).

@philipl
Copy link
Member

philipl commented Oct 17, 2018

Ok, I went and dug out my windows installation and updated drivers, etc, etc.

The first observation for everyone who isn't @shinchiro is you must set your --gpu-api=opengl and you must make sure it uses the 'win' context rather than angle. Interop only works with the real system opengl and angle wraps directx.

Based on the errors I saw, I think this is why people don't see any error messages.

When I switched my backend and context correct, I saw what @shinchiro saw - nvdec-copy works with symbol loading and nvdec does not. In my case I also saw a specific error (I think it prints to stdout which is why @shinchiro may have missed it) that said it can't load cuInit.

That basically must mean it can't find nvcuda.dll or it's finding the wrong one. The dll finding logic is in the headers and should be the same in both ffmpeg and mpv. So that's weird.

@BtbN, any thoughts?

@philipl
Copy link
Member

philipl commented Oct 17, 2018

Continuing. the headers do symbol loading in a simplified way vs ffmpeg, and this is probably where the difference comes from. I guess it's too simple to actually work on windows.

@philipl
Copy link
Member

philipl commented Oct 17, 2018

@BtbN found and fixed the problem.

FFmpeg/nv-codec-headers@5054a06

@shinchiro if you rebuild with the new nv-codec-headers, it should start working.

@shinchiro
Copy link
Contributor

Yeah, that fixed it 👍

@BtbN
Copy link
Contributor

BtbN commented Oct 17, 2018 via email

@Doofussy2
Copy link
Author

Thanks for figuring it out, guys. I look forward to testing it

@Doofussy2
Copy link
Author

I'm a little confused. First, nvdec is working as expected. But I'm not sure cuda, is.
Portable mpv log.txt

This is what I see in the log

[ 0.413][v][vd] Opening decoder hevc
[ 0.413][v][vd] Looking at hwdec hevc_cuvid-cuda...
[ 0.413][v][vo/gpu] Loading hwdec driver 'd3d11-egl'
[ 0.413][v][vo/gpu] Loading failed.
[ 0.413][v][vo/gpu] Loading hwdec driver 'd3d11-egl-rgb'
[ 0.413][v][vo/gpu] Loading failed.
[ 0.413][v][vo/gpu] Loading hwdec driver 'dxva2-egl'
[ 0.413][v][vo/gpu] Loading failed.
[ 0.413][v][vo/gpu] Loading hwdec driver 'd3d11va'
[ 0.413][v][vo/gpu] Loading failed.
[ 0.413][v][vo/gpu] Loading hwdec driver 'dxva2-dxgi'
[ 0.413][v][vo/gpu] Loading failed.
[ 0.413][v][vo/gpu] Loading hwdec driver 'dxva2-dxinterop'
[ 0.413][v][vo/gpu] Loading failed.
[ 0.413][v][vo/gpu] Loading hwdec driver 'cuda-nvdec'
[ 0.549][v][vd] Trying hardware decoding via hevc_cuvid-cuda.
[ 0.549][v][vd] Using underlying hw-decoder 'hevc_cuvid'
[ 0.549][v][vd] Pixel formats supported by decoder: cuda nv12
[ 0.549][v][vd] Codec profile: unknown (0xffffff9d)
[ 0.549][v][vd] Requesting pixfmt 'cuda' from decoder.
[ 0.551][d][ffmpeg/video] hevc_cuvid: CUVID capabilities for hevc_cuvid:
[ 0.551][d][ffmpeg/video] hevc_cuvid: 8 bit: supported: 1, min_width: 144, max_width: 8192, min_height: 144, max_height: 8192
[ 0.551][d][ffmpeg/video] hevc_cuvid: 10 bit: supported: 1, min_width: 144, max_width: 8192, min_height: 144, max_height: 8192
[ 0.551][d][ffmpeg/video] hevc_cuvid: 12 bit: supported: 1, min_width: 144, max_width: 8192, min_height: 144, max_height: 8192
[ 0.553][v][vd] Selected codec: hevc (HEVC (High Efficiency Video Coding))

And the stats says it isn't.

snapshot_66

@philipl
Copy link
Member

philipl commented Oct 20, 2018

That's a 10bit encoding and your hardware doesn't support decoding those, so it's correctly falling back to software.

@Doofussy2
Copy link
Author

Doofussy2 commented Oct 20, 2018

That's not true. I get hwdec with nvdec, nvdec-copy, cuda-copy, auto-copy, d3d11va and d3d11va-copy. cuda is the only one that fails.

log with nvdec enabled
Portable mpv log.txt

[ 0.648][i][vd] Using hardware decoding (nvdec).
[ 0.648][v][vd] Decoder format: 3840x1604 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/auto SP=43.320000 CL=unknown (auto 0.000000/0.000000/0.000000)
[ 0.648][v][vd] Using container aspect ratio.
[ 0.648][v][vf] [in] 3840x1604 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/display SP=43.320000 CL=mpeg2/4/h264
[ 0.648][v][vf] [userdeint] 3840x1604 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/display SP=43.320000 CL=mpeg2/4/h264
[ 0.648][v][vf] [userdeint] (disabled)
[ 0.648][v][vf] [autorotate] 3840x1604 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/display SP=43.320000 CL=mpeg2/4/h264
[ 0.648][v][vf] [autorotate] (disabled)
[ 0.648][v][vf] [convert] 3840x1604 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/display SP=43.320000 CL=mpeg2/4/h264
[ 0.648][v][vf] [convert] (disabled)
[ 0.648][v][vf] [out] 3840x1604 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/display SP=43.320000 CL=mpeg2/4/h264

@Doofussy2
Copy link
Author

I think I see why. I was starting playback with --fs. If I start playback without that, cuda is enabled.

@philipl
Copy link
Member

philipl commented Oct 20, 2018

Looking at your full log, yes, what I see is it trying to use cuda and then that failing. Specifically:

[   0.815][d][vo/gpu] Resizing texture: 3840x1604
[   0.828][e][ffmpeg/video] hevc_cuvid: av_hwframe_get_buffer failed
[   0.828][w][vd] Error while decoding frame!
[   0.839][d][ao/wasapi] Thread Reset
[   0.851][e][ffmpeg/video] hevc_cuvid: av_hwframe_get_buffer failed
[   0.851][w][vd] Error while decoding frame!
[   0.861][e][ffmpeg/video] hevc_cuvid: av_hwframe_get_buffer failed
[   0.861][w][vd] Error while decoding frame!
[   0.861][e][ffmpeg/video] hevc_cuvid: av_hwframe_get_buffer failed
[   0.861][w][vd] Error while decoding frame!
[   0.946][w][vd] Falling back to software decoding.

I can somewhat imagine this is related to --fs being used, but I'm surprised to hear it.

Note that the difference between cuda and nvdec is that cuda uses the nvidia parser and codec implementation while nvdec plugs the decoder into the ffmpeg codec using the hwaccel mechanism. Differences in parser and codec features can produce different results (usually the nvidia stuff is more limited than the ffmpeg equivalents), and ultimately the only reason to use cuda over nvdec is that you want to do deinterlacing, which is only possible with cuda.

@Doofussy2
Copy link
Author

Yeah, I used to enable cuda/cuda-copy for the deinterlacing feature, but then discovered that cuda/cuda-copy can't decode half of my HDR stuff. The picture breaks up, very badly, and freezes. All other decoders are just fine. So I won't be using cuda, I just thought I'd bring it to your attention, in case there was problem. It definitely doesn't work with --fs. Thanks for all the good work, guys.

@philipl
Copy link
Member

philipl commented Oct 20, 2018

There definitely seem to be nvidia parser/codec issues with HDR stuff. I've seen it too, but fortunately there's no interlaced HDR :-) I'm glad it's working reasonably now.

@Doofussy2
Copy link
Author

Ha! Yeah, I've had some major issues with deinterlacing. I've had to make auto-profiles, to work around it.

Thanks again

@Doofussy2
Copy link
Author

I hope @lachs0r will add this to the next release :)

@Doofussy2
Copy link
Author

Doofussy2 commented Oct 21, 2018

A quick revision for enabling cuda. I thought it was --fs that was causing the problem, but it looks like it's more to do with full frame 4k HDR. If I play a cropped 4k HDR video, cuda is enabled. If I play a full frame 4k HDR, it doesn't enable. With 4k SDR, it appears to work ok.

@sfan5 sfan5 closed this as completed Oct 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests