Forum › Forums › General › Tips and Tricks › mpv –hwdec=auto
- This topic has 30 replies, 9 voices, and was last updated Mar 31-1:05 pm by subluminal.
-
AuthorPosts
-
March 29, 2022 at 1:48 pm #80093Member
ModdIt
::Hi subluminal,
been trying to understand how to setup/useuse the tools you are developing and pointing to, still
very unsure whether doing things in the correct manner.,
Your knowledge on the subject is miles ahead, I think that will probably apply to others here in the forum.Wishlist, a step by step how to for newbs, proper setup and basic usage, that should be enough to get us started
with things working correctly.Then we can make a backup before exploring, er, in my case breaking things and hopefully figuring which settings do
what and why. ๐March 29, 2022 at 2:59 pm #80094Membercalciumsodium
::Hi @subluminal,
Thank you for the explanation about the default video output for mpv. Now I understand why on my newer machines, the video out goes straight to gpu. Whereas on my older machines, I first see an error about vo/gpu/opengl. Then I see an error vo/vdpau. I suppose that it tries the gpu vo first. Then it tries the vdpau vo. Then it tries vo/xv and sees success. Then the video finally launches with xv vo.
ThanksMarch 29, 2022 at 9:32 pm #80118Membersubluminal
::@calciumsodium. Nice name btw. And yes, mpv checks vo=gpu 1st, if it’s available, mpv will use that by default (unless you specifically use vo=something else in mpv.conf. Not recommended though. In my experience, vo=gpu works best. When I had a Pentium IV cpu, in my previous ancient machine, mpv used vo=xv. Anything in the past 10-15 years (for instance, in my current ancient machine), mpv uses vo=gpu.
@moddit I left some rudimentary instructions in my github repo that I linked earlier. For someone completely new to mpv, it might be a touch harder to follow. I left out quite a few explanations because mpv is vast, not to mention youtube-dl and especially ffmpeg(filters). I use all 3 although I’m not as familiar with ffmpeg. It is even more vast. ๐
It is also very hard to write a guide of sorts because most if not all the settings are hardware-dependent. So if someone has a RTX 3070 (laptop) GPU, he/she can go berserk and apply the highest quality settings. If someone has say a GTX 1650 (laptop) GPU he can still probably get the best quality settings IF used with height-profiles.lua which sets up conditional profiles based on video height. I used laptop GPU example because laptop GPUs are typically much less powerful than the desktop counterpart of the same model(because of heat constraints I guess). If someone has say i5 6th gen, FSRCNNX with ewa_lanczossharp+motion interpolation+debanding+KrigBilateral+SSimDownScaler+mitchell – this high quality combo might stretch the GPU too much. Also depends on video codec and Monitor/TV resolution of course.
If you have to compromise, use an average cscaler (say bicubic_fast). This is because Human eye cannot distinguish as well between crappy quality image containing chrome(color). Human eye is far more sensitive to Luma(greyscale). It probably points to our evolution. Most animals cannot see color. We also have far more rod cells(used to see luma) than cone cells(used for color detection). 20 times as many on average.
So use a crappy cscaler, and as good a scaler(luma) as your GPU can manage. The inbuilt deband option of mpv is great and versatile but eats a lot of resource. If not required, turn off debanding although depending on the source, it will reduce quality. I always use debanding myself.
mpv also has decent tscalers, fast but nowhere near as good as SVP. oversample or box(with sphinx tscale-window) is a good option.
hwdec=auto-copy is ok if your GPU is old-ish(or iGPU which isn’t vega). The vega iGPUs are awesome. Keep in mind, if you do hardware decoding, say vaapi, some ffmpeg filters won’t work. Like hue(use mpv’s –hue option then, it works). SVP won’t work.
If video is 480p and Monitor 1080p, 2X luma upscaling( ravu, FSRCNN, SSimSuperRes are all 2X luma upscaler) won’t be enoguh as 2*480=960. So either use luma upscalers twice(gpu intensive) or let mpv do upscaling from 960p to 1080p using scale=something option. I use ewa_lanczossharp but it’s also GPU intensive. spline64 is another less resource-hungry option. If you do use 2*2X glsl shaders, you then need to downscale using dscale=mitchell(best dscaler) or using SSimDownScaler(which also sharpens a little). Unless of course video is exactly 1080/4=270p.
Post is getting too long. As I said, too many things to explain. Ask me if you have questions.
Sorry, you said basic usage. To get started. Change if and when necessary:
vo=gpu
hwdec=auto-safe
fullscreen=yes
ytdl-format=bv*+ba/best # For yt-dlp
ytdl-raw-options=no-playlist=
script-opts-append=ytdl_hook-ytdl_path=/usr/local/bin/yt-dlp
video-sync=display-resample
scale=spline64
cscale=bilinear
deband=yes
interpolation=yes
tscale=oversample
dscale=mitchell
volume-max=150Also, add this in input.conf for voice clarity.
n cycle_values af loudnorm=I=-15 anull
- This reply was modified 1 year, 1 month ago by subluminal.
- This reply was modified 1 year, 1 month ago by subluminal.
- This reply was modified 1 year, 1 month ago by subluminal.
March 30, 2022 at 9:10 am #80136MemberModdIt
::Hi subluminal, agree on vast subject. Thanks for quick guide, I have read the git instructions, as you note not enough for me to be
sure I am doing things correctly.With i5-2500K CPU @ 3.30GHz and GTX550 TI Nvidia Legacy driver I had a huge amount of dropped frames very low CPU usage, about 9%.
Judging by GPU temp it was not working really hard, or just parts of the core were in overload.
Monitor is LG @ 1920*1080On the weekend I picked up a GK208B [GeForce GT 710] passive cooled clocked @33MHz 2GB Video Memory. Now fitted and on Latest Nvidia driver from repo.
The issue with a lot of frames dropped is greatly reduced maybe gone
I had issues with screen tearing. adding below to desktop session startup seems to have improved the situation. origin, I think posted by caprea# Set nvidia driver non-screen tearing mode nvidia-settings --assign CurrentMetaMode="nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }" &CPU load still very low while watching some teat videos yesterday, GPU hovering around 40 ยฐC which is very safe.
Will post again once I have meaningful info on the new combination of hardware software setup. High GPU Temperature may be an issue due
passive cooling. If so it will get a quiet fan and home made duct directed airflow .- This reply was modified 1 year, 1 month ago by ModdIt.
March 30, 2022 at 12:13 pm #80148Membersubluminal
::Hi @Moddit. Thanks for the info. I’m not very familiar with Nvidia GPUs so can’t be of much help with screen tearing. But others, I can provide some input.
mpv loads vo in the order it is listed when you run ‘mpv –vo=help’. What vo is your system using?
Also, you could try setting (in Global Setting) deband=no and then make a new profile called deband-cond by putting this in mpv.conf.
[deband-cond]
profile-restore=copy
deband=yes
deband-iterations=2
deband-range=16
deband-threshold=48
deband-grain=96Higher threshold = more debanding = Less compression/blocky artifacts = Less Details in certain areas.
Grain adds dynamic grain so video doesn’t look flat.
Iteration more than 3 isn’t particularly useful. More iterations = More debanding.
Range = 16 is the default. Could skip that.Also use this in input.conf to trigger this profile if and when you need to deband, i.e. when video has compression artifacts. (For viewing images, deband isn’t necessary.)
Shift+d apply-profile “deband-cond”
Shift+u apply-profile “deband-cond” restoreSo Shift+d applies and Shift+u restores(undoes).
This should lower GPU usage. CPU won’t be used unless video has av1 codec or you use mpv –profile=sw-fast.
Also add in mpv.conf for voice clarity+auto adjustment of loud and soft sound:
af-add=lavfi=[acompressor,loudnorm=I=-15]Change default volume as this will increase it.
volume=80
volume-max=150For viewing online say youtube videos, youtube always encodes in avc1 and vp9 and av1 for some videos. av1 is much higher compression and mpv uses dav1d ( CPU based decoder). So IF your GPU can only decode h264/avc1 and not vp9,av01,hevc/h265, change ytdl-format option:
ytdl-format=bv*[vcodec^=avc1][height<=?1080]+ba/best
Test it with this:
mpv https://www.youtube.com/watch?v=qj139dE7tFICheers !
P.S: You said dropped frames “may be” gone. Press Shift+i during runtime, the stats shown will have “dropped frames”. If its in single digits you’re good. Shift+i then ‘2’opens another stats window where you can see scalers/debanding/interpolation stats, then ‘1’ press brings you back to the previous stats window. “dropped frames” stat will be missing without video-sync=display-* ( I use display-resample with –interpolation=yes and tscale=box and –tscale-window=sphinx). But tscale=oversample is also good.
Btw, profiles should always be set AFTER all the Global settings.
Good luck.
- This reply was modified 1 year, 1 month ago by subluminal.
- This reply was modified 1 year, 1 month ago by subluminal.
March 30, 2022 at 12:38 pm #80152MemberModdIt
::Hallo subluminal, thanks for the suggestions, will be a job for this evening. Command applied as requested
the forum software mangles things like minus minus so better to set code tag before and after commands
or lists containing commands.$ mpv --vo=help Available video outputs: libmpv render API for libmpv gpu Shader-based GPU Renderer vdpau VDPAU with X11 wlshm Wayland SHM video output (software scaling) xv X11/Xv sdl SDL 2.0 Renderer vaapi VA API with X11 x11 X11 (software scaling) null Null video output image Write video frames to image files tct true-color terminals caca libcaca drm Direct Rendering Manager (software scaling) sixel libsixelMarch 30, 2022 at 12:52 pm #80156Membersubluminal
::Use vo=gpu.
Also, forgot to add, IF you intend to view 2K/4K videos from youtube, youtube may not have avc1 for those content since vp9/av1 take much less space in their servers.
And for other sites, vcodecs may vary. avc1 may not be available. Change ytdl-format accordingly. GT 710 should be able handle vp9 even without hw decoding enabled. Also, 2K/4K content on 1080p monitor would require downscaling. Bilinear is worst and fastest. ewa_lanczossharp/soft very sharp. Too sharp for me. I use mitchell/catmull_rom.
- This reply was modified 1 year, 1 month ago by subluminal.
March 30, 2022 at 4:38 pm #80174MemberModdIt
::Again thanks for help and input,
will need a few days to experiment and hopefully begin to understand what I am doing. ๐GT 710 should be able handle vp9, according to post on open video org yes. NVidia considers the card deprecated so no info
from there.March 30, 2022 at 5:27 pm #80175Membersubluminal
::Another thing that I mentioned in passing earlier, I think it may be relevant for a lot of people here.
profile=sw-fast is good for old hardware. Check if it’s available 1st using ‘mpv –profile=help’
sw-fast may not be available before version 0.30-ish. It’s certainly available in 0.33 and may be even 0.32.
Cheers !!
P.S: Keep in mind, sw-fast uses software and should probably not be used if your GPU can decode the video codec.
- This reply was modified 1 year, 1 month ago by subluminal.
March 30, 2022 at 6:53 pm #80180MemberModdIt
::So now we know
[ffmpeg/video] vp9: Hardware is lacking required capabilities
[ffmpeg/video] vp9: Failed setup for format cuda: hwaccel initialisation returned error.
VO: [gpu] 1920×1080 yuv420p
AV: 00:04:35 / 00:04:35 (100%) A-V: 0.000 DS: 2.460/235 Dropped: 216 Cache: 0.0Playing: https://youtube.com/watch?v=JEp7QrOBxyQ
AV: 00:04:35 / 00:04:35 (100%) A-V: 0.000 DS: 2.460/235 Dropped: 216 Cache: 0.0
(+) Video –vid=1 (*) (vp9 1920×1080 23.976fps)
(+) Audio –aid=1 –alang=eng (*) (opus 2ch 48000Hz)But video quality already improved, colours, somewhat like setting for vivid gives on my Lumix.
Playback more fluid. Seemed like less artefacts. Quite a few frames dropped.Guessing software decoding was used.
March 30, 2022 at 7:12 pm #80183Member
blur13
::I’ve got
ytdl-format=bestvideo[height<=?720][fps<=?30][vcodec!=?vp9]+bestaudio/beston my laptop and
ytdl-format=bestvideo[height<=?1080][fps<=?30][vcodec!=?vp9]+bestaudio/beston my desktop. Higher resolution would just be wasted on a screen that can’t handle it. And it avoids the vp9 codec which gives me nothing but trouble.
I didnt invent this, its taken from the following comment
This is a slightly more advanced way: It picks the best format it can find (up to but not above 1080p), chooses 30fps or lower (since 60fps just leads to dropped frames and stutter on my computer), and lastly it also ignores the stupid VP9 codec.
ytdl-format=bestvideo[height<=?1080][fps<=?30][vcodec!=?vp9]+bestaudio/best
If you want to limit it to 720p30 or lower, use this instead:
ytdl-format=bestvideo[height<=?720][fps<=?30][vcodec!=?vp9]+bestaudio/best
No matter what you do, I highly recommend using one of these lines in your mpv.conf. Otherwise it always picks the highest-quality version, which may mean 4K @ 60 fps = hell for your CPU to decode, and a total waste of bandwidth!
https://github.com/mpv-player/mpv/issues/4241
Its been working really well for me.
March 30, 2022 at 7:35 pm #80184Membersubluminal
::@blur13, On my setup, I have max 1080p same way you do but I always like to view 60fps when it’s available. Butter smooth. ๐
@Moddit, yes your GPU can’t do vp9 decoding. Use ytdl-format to select avc1 vcodec when available. Your GPU can do hardware decoding for avc1/h264.
Check if frames are being dropped. Shift+i as I said earlier.
๐ What the hell!!! It says
*** Forbidden. Your IP belongs to a high spam risk network. ***
when I try to post.
Oh no, just noticed — got mangled everywhere as you said. Sorry about that.
@Moddit, This is strange. I played the same video(https://youtube.com/watch?v=JEp7QrOBxyQ) that you posted. Worthy message and a nice song. And I didn’t get a single dropped frame. What settings are you using in mpv.conf? Your GPU is much faster than the GPU of the machine I’m on. Try this please and see if you get dropped frame.
mpv --vo=gpu --no-config --ytdl-format=248+ba --fs --video-sync=display-resample --hr-seek-framedrop=no --interpolation-threshold=-1 --deband=no --scale=bilinear --cscale=bilinear --interpolation=yes --tscale=box --tscale-window=sphinx --tscale-radius=1.05 --tscale-antiring=1.0 --tscale-blur=0.9 https://youtube.com/watch?v=JEp7QrOBxyQ- This reply was modified 1 year, 1 month ago by subluminal.
- This reply was modified 1 year, 1 month ago by subluminal.
- This reply was modified 1 year, 1 month ago by subluminal.
March 31, 2022 at 10:21 am #80229MemberModdIt
::subluminal wrote๐ What the hell!!! It says
*** Forbidden. Your IP belongs to a high spam risk network. ***
when I try to post.Unfortunately nothing unusual of late. The site is so well protected I often can not even reach it, really annoys me.
My IP adress, actualy an exit point changes multiple times a day sometimes within a few minutes due provider load
balancing routing choices. that seems to really irritate the Artificial idiot, KI.Back on topic, I am experimenting with profiles, the setup you last posted gave no dropped frames but video quality was
not as good as some of my previous trials. Sound distorted unless the sound correction used. Video was chosen due its message,
I like it. Playing for change, musik and video quality are, for youtube pretty good so all fits.
Sound is going through one of the better audigy cards which at times can be more complicated, output quality makes up for that.af-add=lavfi=[acompressor,loudnorm=I=-15] volume=80 volume-max=150March 31, 2022 at 11:19 am #80231Membersubluminal
::@Moddit you said video quality wasn’t as good as your previous trials. What settings were you using then?
Of course, in general, better quality settings = more GPU resource. ๐ But that is why I use conditional profiles so that I can use HQ settings for SD videos and basic settings for FHD+. So you shouldn’t use scale=bilinear(default) if your video is 480p and monitor 1080p. Also as I said, debanding has its advantages (better images quality unless you go crazy and use deband-iterations=3 or 4) and disadvantages (resource-intensive).
- This reply was modified 1 year, 1 month ago by subluminal.
March 31, 2022 at 12:11 pm #80235MemberModdIt
::Hi subluminal,
full setup from your git page and below giving best graphics quality up to now.
In the config from Git I have added the audio settings and deactivated the redirect for ytdl, as yet no other changes.vo=gpu
hwdec=auto-safe
fullscreen=yes
ytdl-format=bv*+ba/best # For yt-dlp
ytdl-raw-options=no-playlist=
script-opts-append=ytdl_hook-ytdl_path=/usr/local/bin/yt-dlp
video-sync=display-resample
scale=spline64
cscale=bilinear
deband=yes
interpolation=yes
tscale=oversample
dscale=mitchell
volume-max=150
n cycle_values af loudnorm=I=-15 anullWith regard to system load my desktop device is absolute overkill for everyday usage. CPU GPU
not going over 35ยฐC. The newer GPU is much more energy
efficient/cooler running @ about 30W than the card it replaced @ TDP 116W plus more for extra
cooling.The biggest bugbear with continued usage of older devices is energy efficiency to performance
ratio. With very high energy prices as at present I will need to change my habits and use phone
or netbook much more.- This reply was modified 1 year, 1 month ago by ModdIt.
-
AuthorPosts
- You must be logged in to reply to this topic.