mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.16k stars 2.89k forks source link

cuda or nvdec accelerated denoise filter? #7895

Closed MPdaedalus closed 4 years ago

MPdaedalus commented 4 years ago

Hi

Just getting to grips with mpv, everything working except denoise filter, I tried vf=lavfi="hqdn3d" in config but when I play video I get>

 (+) Video --vid=1 (*) (vp9 3840x2160 59.940fps)
 (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
AO: [pulse] 48000Hz stereo 2ch float
Using hardware decoding (nvdec).
[ffmpeg] Impossible to convert between the formats supported by the filter 'mpv_src_in0' and the filter 'auto_scaler_0'
[lavfi] failed to configure the filter graph
Disabling filter lavfi.00 because it has failed.
VO: [gpu] 3840x2160 cuda[nv12]
my config>
hwdec=nvdec
vo=gpu
video-sync=display-resample
ytdl-format="bestvideo[ext=webm][vcodec=vp9]+bestaudio[ext=webm]"
interpolation=yes
scale=ewa_lanczossharp
dscale=mitchell
tscale=mitchell
deband=yes
vf=lavfi="hqdn3d"

same problem when using the cycle_denoise-denoise lua script

[ffmpeg] Impossible to convert between the formats supported by the filter 'mpv_src_in0' and the filter 'auto_scaler_0' [lavfi] failed to configure the filter graph Disabling filter cycle_denoise-denoise because it has failed.

Even if I could get it to work I doubt my crappy old i5 could do real time cpu denoise on 8k 60 so it must use my GTX 1060 gpu for denoise either via cuda cores or preferably the video engine itself which is working fine for the actual decode, 8k 60fps vp9 is nice and smooth. My nvidia driver says it can do noise reduction but this is on the vdpau page which I can't use for 4k vp9 or 10bit hevc.

Thanks in advance

mpv 0.32.0 Copyright © 2000-2020 mpv/MPlayer/mplayer2 projects built on UNKNOWN ffmpeg library versions: libavutil 56.31.100 libavcodec 58.54.100 libavformat 58.29.100 libswscale 5.5.100 libavfilter 7.57.100 libswresample 3.5.100 ffmpeg version: 4.2.3

on fedora 32 kernel 5.7.7 NVIDIA driver 440.100

ghost commented 4 years ago

You can use cuda-copy. Automatic behavior is not really easily possible, because ffmpeg filters do not report what inputs they support.

philipl commented 4 years ago

Someone could write a cuda based denoise filter in ffmpeg, but you need to find that someone.

MPdaedalus commented 4 years ago

tried cuda copy and denoise seems to work, no error messages, however I get a pathetic 8fps on just a 4k 24fps video, it still seems to be using my cpu to do the denoise and only single threaded at that, mpv cpu at 100% on 1 core only. Maybe hqdn3d is too heavy and I should try a simpler denoiser but I think hardware denoise will be my only option for 4k60 and above.

haasn commented 4 years ago

This would probably be easiest to implement as a custom GLSL shader.

Traneptora commented 4 years ago

libavfilter's hqdn3d is extremely slow, like most CPU denoisers, and cannot do realtime denoising. You're better off doing realtime denoising with KNLMeansCL in vapoursynth, and using --vf=vapoursynth.