How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Questions about hardware, drivers and peripherals
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
FFIXCollector
Level 2
Level 2
Posts: 68
Joined: Sat Jun 14, 2014 9:07 am

How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by FFIXCollector »

Back in the day, VDPAU allowed the video processing to be offloaded onto the GPU providing much smoother video, and faster performance when video editing.
It seems that the VDPAU driver is no longer proprietary to NVidia.

How do I check that the GPU is being utilized properly? I have a GeForce GTX 460
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
gm10

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by gm10 »

For VDPAU:

Code: Select all

vdpauinfo
For VA-API:

Code: Select all

vainfo
That only tells you if the drivers are in place though. Utilizing them depends on your application.
User avatar
trytip
Level 14
Level 14
Posts: 5366
Joined: Tue Jul 05, 2016 1:20 pm

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by trytip »

in nvidia-settings you will have detailed info on vdpau. only way to really test it is select vdpau in vlc or smplayer and play a bitrate demanding video then check your cpu.

ps: smplayer has good log on what's played. first select
smplayer >preferences > general > general > multimedia engine:mplayer
smplayer >preferences > general > video > output driver:vdpau

while playing a video select view > mplayer/mpv log and scroll to the bottom you will see VO:

Code: Select all

AO: [pulse] 48000Hz 2ch floatle (4 bytes per sample)
ID_AUDIO_CODEC=ffaac
Starting playback...
Movie-Aspect is 2.30:1 - prescaling to correct movie aspect.
ID_VIDEO_ASPECT=2.3043
VO: [vdpau] 848x368 => 848x368 H.264 VDPAU acceleration 
Movie-Aspect is 2.30:1 - prescaling to correct movie aspect.
ID_VIDEO_ASPECT=2.3043
VO: [vdpau] 848x368 => 848x368 H.264 VDPAU acceleration 
smplayer log is also there but you want the engine output not the UI output
Image
gm10

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by gm10 »

trytip wrote: Wed Aug 15, 2018 1:39 pm in nvidia-settings you will have detailed info on vdpau. only way to really test it is select vdpau in vlc or smplayer and play a bitrate demanding video then check your cpu.
Just run them from the command line, they'll tell you what pipeline they're using to output, e.g. for my intel chip:
vlc: avcodec decoder: Using OpenGL/VAAPI backend for VDPAU for hardware decoding
mpv: Using hardware decoding (vaapi).
User avatar
trytip
Level 14
Level 14
Posts: 5366
Joined: Tue Jul 05, 2016 1:20 pm

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by trytip »

for me i just look at my side conky and i can tell the difference between mpv or smplayer or vlc. playing HD higher 2K file for me uses a lot of cpu since i only have a duocore, but have no issues with bitrate demanding videos using vdpau

here with mpv:vdpau cpu is ok . better than vlc but worse than smplayer/mplayer and i have the same settings in arch:linux mint:17.3 and mint:19

Image

and when i use smplayer with mplayer:vdpau my cpu usage is all the way down

Image

i did create .config/mpv/mpv.conf using it to access vdpau, there are many settings you can get from mvp master. it may work for you or not. it may only work with nvidia drivers

Code: Select all

#
#
###########
# General #
###########
#
geometry=50%:50%
autofit-larger=100%x95%
cursor-autohide=4500
osd-duration=4500
save-position-on-quit
#
#
################
# Video Output #
################
#
#vo=vdpau   # comment out if framerate skips
vo=gpu  # needs upfdated mpv  *mpv --vo=help* in terminal gives you available vo=
hwdec=vdpau
hwdec-codecs=all
video-output-levels=full
#
#
#########
# Audio #
#########
#
volume-max=200
volume=100
#mpv [filepath] --script=/home/user/.config/mpv/acompressor.lua  *in terminal
#create a folder called .config/mpv/scripts and paste acompressor.lua there  *use N to activate
#
#
#########
# Cache #
#########
#
cache=no
cache-default=5000000
cache-backbuffer=25000
cache-initial=0
cache-secs=10
#
#
#############
# Subtitles #
#############

sub-auto=fuzzy                          # external subs don't have to match the file name exactly to autoload
sub-file-paths-append=ass               # search for external subs in these relative subdirectories
sub-file-paths-append=srt
sub-file-paths-append=sub
sub-file-paths-append=subs
sub-file-paths-append=subtitles

demuxer-mkv-subtitle-preroll            # try to correctly show embedded subs when seeking
embeddedfonts=yes                       # use embedded fonts for SSA/ASS subs
sub-fix-timing=no                       # do not try to fix gaps (which might make it worse in some cases)
sub-ass-force-style=Kerning=yes         # allows you to override style parameters of ASS scripts
sub-use-margins
sub-ass-force-margins

# the following options only apply to subtitles without own styling (i.e. not ASS but e.g. SRT)
sub-font="DejaVu Sans Book"
#sub-font="Roboto"
sub-font-size=56
sub-color="#EFEFEF"
sub-border-color="#2F343F"
sub-border-size=3.7
sub-shadow-offset=1
sub-shadow-color="#000000"
sub-spacing=0.5
#
#
Last edited by trytip on Fri Aug 17, 2018 10:25 am, edited 6 times in total.
Image
FFIXCollector
Level 2
Level 2
Posts: 68
Joined: Sat Jun 14, 2014 9:07 am

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by FFIXCollector »

Here is what I get from mpv:

Code: Select all

 (+) Video --vid=1 (*) (hevc 3840x2160 29.970fps)
 (+) Audio --aid=1 --alang=und (*) (aac 2ch 48000Hz)
VO does not support requested hardware decoder, or loading it failed.
AO: [pulse] 48000Hz stereo 2ch float
VO: [opengl] 3840x2160 yuv420p
AV: 00:00:05 / 00:00:48 (12%) A-V:  0.489 Dropped: 86

Audio/Video desynchronisation detected! Possible reasons include too slow
hardware, temporary CPU spikes, broken drivers, and broken files. Audio
position will not match to the video (see A-V status field).

(Paused) AV: 00:00:15 / 00:00:48 (31%) A-V:  2.761 Dropped: 283


Exiting... (Quit)
vdpauinfo:

Code: Select all

display: :0   screen: 0
API version: 1
Information string: NVIDIA VDPAU Driver Shared Library  390.48  Wed Mar 21 23:47:29 PDT 2018

Video surface:

name   width height types
-------------------------------------------
420     4096  4096  NV12 YV12 
422     4096  4096  UYVY YUYV 

Decoder capabilities:

name                        level macbs width height
----------------------------------------------------
MPEG1                           0  8192  2048  2048
MPEG2_SIMPLE                    3  8192  2048  2048
MPEG2_MAIN                      3  8192  2048  2048
H264_BASELINE                  41  8192  2048  2048
H264_MAIN                      41  8192  2048  2048
H264_HIGH                      41  8192  2048  2048
VC1_SIMPLE                      1  8190  2048  2048
VC1_MAIN                        2  8190  2048  2048
VC1_ADVANCED                    4  8190  2048  2048
MPEG4_PART2_SP                  3  8192  2048  2048
MPEG4_PART2_ASP                 5  8192  2048  2048
DIVX4_QMOBILE                   0  8192  2048  2048
DIVX4_MOBILE                    0  8192  2048  2048
DIVX4_HOME_THEATER              0  8192  2048  2048
DIVX4_HD_1080P                  0  8192  2048  2048
DIVX5_QMOBILE                   0  8192  2048  2048
DIVX5_MOBILE                    0  8192  2048  2048
DIVX5_HOME_THEATER              0  8192  2048  2048
DIVX5_HD_1080P                  0  8192  2048  2048
H264_CONSTRAINED_BASELINE      41  8192  2048  2048
H264_EXTENDED                  41  8192  2048  2048
H264_PROGRESSIVE_HIGH          41  8192  2048  2048
H264_CONSTRAINED_HIGH          41  8192  2048  2048
H264_HIGH_444_PREDICTIVE       41  8192  2048  2048
HEVC_MAIN                      --- not supported ---
HEVC_MAIN_10                   --- not supported ---
HEVC_MAIN_STILL                --- not supported ---
HEVC_MAIN_12                   --- not supported ---
HEVC_MAIN_444                  --- not supported ---

Output surface:

name              width height nat types
----------------------------------------------------
B8G8R8A8         16384 16384    y  Y8U8V8A8 V8U8Y8A8 A4I4 I4A4 A8I8 I8A8 
R10G10B10A2      16384 16384    y  Y8U8V8A8 V8U8Y8A8 A4I4 I4A4 A8I8 I8A8 

Bitmap surface:

name              width height
------------------------------
B8G8R8A8         16384 16384
R8G8B8A8         16384 16384
R10G10B10A2      16384 16384
B10G10R10A2      16384 16384
A8               16384 16384

Video mixer:

feature name                    sup
------------------------------------
DEINTERLACE_TEMPORAL             y
DEINTERLACE_TEMPORAL_SPATIAL     y
INVERSE_TELECINE                 y
NOISE_REDUCTION                  y
SHARPNESS                        y
LUMA_KEY                         y
HIGH QUALITY SCALING - L1        y
HIGH QUALITY SCALING - L2        -
HIGH QUALITY SCALING - L3        -
HIGH QUALITY SCALING - L4        -
HIGH QUALITY SCALING - L5        -
HIGH QUALITY SCALING - L6        -
HIGH QUALITY SCALING - L7        -
HIGH QUALITY SCALING - L8        -
HIGH QUALITY SCALING - L9        -

parameter name                  sup      min      max
-----------------------------------------------------
VIDEO_SURFACE_WIDTH              y         1     4096
VIDEO_SURFACE_HEIGHT             y         1     4096
CHROMA_TYPE                      y  
LAYERS                           y         0        4

attribute name                  sup      min      max
-----------------------------------------------------
BACKGROUND_COLOR                 y  
CSC_MATRIX                       y  
NOISE_REDUCTION_LEVEL            y      0.00     1.00
SHARPNESS_LEVEL                  y     -1.00     1.00
LUMA_KEY_MIN_LUMA                y  
LUMA_KEY_MAX_LUMA                y  


What do I need to do to get this working?
User avatar
trytip
Level 14
Level 14
Posts: 5366
Joined: Tue Jul 05, 2016 1:20 pm

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by trytip »

i did create .config/mpv/mpv.conf using it to access vdpau
copy the code i made, or make your own and put it in .config/mpv/mpv.conf

ps: i missed the part you trying to access acceleration for hevc file, that's not possible yet. x265 doesn't have hardware support.
it says so in your vdpauinfo also:

Code: Select all

HEVC_MAIN                      --- not supported ---
HEVC_MAIN_10                   --- not supported ---
HEVC_MAIN_STILL                --- not supported ---
HEVC_MAIN_12                   --- not supported ---
HEVC_MAIN_444                  --- not supported ---
Image
FFIXCollector
Level 2
Level 2
Posts: 68
Joined: Sat Jun 14, 2014 9:07 am

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by FFIXCollector »

Got that, but VO is still using openGL
Smplayer is using VDPAU successfully, though I'm surprised that it does not do a better job. a 4k clip still taxes the processors until they max out.

Code: Select all

mpv ~/Desktop/test1.mp4
Playing: ~/Desktop/test1.mp4
 (+) Video --vid=1 (*) (hevc 3840x2160 30.000fps)
 (+) Audio --aid=1 --alang=und (*) (aac 2ch 48000Hz)
AO: [pulse] 48000Hz stereo 2ch float
HEVC video output may be broken due to nVidia bugs.
VO: [opengl] 3840x2160 yuv420p
AV: 00:00:10 / 00:00:48 (22%) A-V:  0.000
Saving state.


Exiting... (Quit)

User avatar
trytip
Level 14
Level 14
Posts: 5366
Joined: Tue Jul 05, 2016 1:20 pm

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by trytip »

trytip wrote: Wed Aug 15, 2018 11:19 pm
i did create .config/mpv/mpv.conf using it to access vdpau
copy the code i made, or make your own and put it in .config/mpv/mpv.conf
so this is the third time i post this. do you have the mpv.conf to tell it to use vdpau? you can create your own or use mine from above posts . here's a master https://github.com/mpv-player/mpv/blob/ ... c/mpv.conf
Last edited by trytip on Thu Aug 16, 2018 10:26 am, edited 1 time in total.
Image
gm10

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by gm10 »

trytip wrote: Thu Aug 16, 2018 9:42 am
trytip wrote: Wed Aug 15, 2018 11:19 pm
i did create .config/mpv/mpv.conf using it to access vdpau
copy the code i made, or make your own and put it in .config/mpv/mpv.conf
so this is the third time i post this. do you have the mpv.conf to tell it to use vdpau? you can create your own or use mine https://github.com/mpv-player/mpv/blob/ ... c/mpv.conf
To be fair, your example above doesn't include the vo parameter that he is having trouble with. For a full list of available outputs, run

Code: Select all

mpv --vo=help
You'll get something like this:

Code: Select all

Available video outputs:
  libmpv           render API for libmpv
  gpu              Shader-based GPU Renderer
  vdpau            VDPAU with X11
  xv               X11/Xv
  sdl              SDL 2.0 Renderer
  vaapi            VA API with X11
  x11              X11 (slow, old crap)
  null             Null video output
  image            Write video frames to image files
  tct              true-color terminals
  caca             libcaca
  drm              Direct Rendering Manager
OP will likely want to pick vdpau or gpu/opengl (depending on mpv version, check your own output). A minimal mpv.conf could look like this, for example:

Code: Select all

vo=vdpau
hwdec=vdpau
hwdec-codecs=all
User avatar
trytip
Level 14
Level 14
Posts: 5366
Joined: Tue Jul 05, 2016 1:20 pm

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by trytip »

vo=vdpau
you don't want to use vdpau for "vo=" just in case you need to to fall back on the cpu if something is not hardware supported which is why for nvidia you let the player choose the best output. you only want to enable the hardware output for files supported, so in my config i don't have a "vo=" because is mainly for integrated graphics

i still don't quite understand these video settings myself to be honest. when i get a video that runs high on my cpu then i look over my mpv.conf
Image
gm10

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by gm10 »

trytip wrote: Thu Aug 16, 2018 4:28 pm
vo=vdpau
you don't want to use vdpau for "vo =" just in case you need to to fall back on the cpu if something is not hardware supported which is why for nvidia you let the player choose the best output. you only want to enable the hardware output for files supported, so in my config i don't have a "vo=" because is mainly for integrated graphics
Fair enough, but OP's problem is that he gets

Code: Select all

VO does not support requested hardware decoder, or loading it failed.
with the opengl output that gets selected by default.

But I don't have nvidia experience under Linux so I'll let you handle this. ;)

Btw, I'm running mpv v0.29 from the cosmic-proposed repo along with updated codecs, lots of good fixes at least for my intel platform.
User avatar
trytip
Level 14
Level 14
Posts: 5366
Joined: Tue Jul 05, 2016 1:20 pm

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by trytip »

if the we play a file with HEVC x265 codec than we all get the same error since x265 is not hardware supported and falls back to cpu. if we play a file with x264 and we get this error than yes something is wrong. we need to know what file format. from the posts above the OP is trying to get x265 to play with acceleration. this is not possible yet as far as i know on current hardware.
Image
gm10

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by gm10 »

trytip wrote: Thu Aug 16, 2018 6:06 pm if the we play a file with HEVC x265 codec than we all get the same error since x265 is not hardware supported and falls back to cpu. if we play a file with x264 and we get this error than yes something is wrong. we need to know what file format. from the posts above the OP is trying to get x265 to play with acceleration. this is not possible yet as far as i know on current hardware.
If it's an option just use your integrated GPU for watching x265 movies then rather than the NVIDIA chip, at least my laptop's Intel HD 500 graphics support HVEC:

Code: Select all

Playing: BigBuckBunny_2000hevc.mp4
 (+) Video --vid=1 (*) (hevc 3840x2160 24.000fps)
Using hardware decoding (vaapi).
VO: [vaapi] 3840x2160 vaapi[nv12]
User avatar
trytip
Level 14
Level 14
Posts: 5366
Joined: Tue Jul 05, 2016 1:20 pm

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by trytip »

@gm10
does the cpu use less % playing x264 compared to x265 ? i am curious about that. i know nothing about integrated graphics, my laptop is about 2 years old but haven't used it much with linux. the mpv config i posted is for stand alone nvidia graphic cards. hopefully the OP has a stand alone, didn't yet ask for inxi -Fxzd :D i'm guessing that would help
Image
gm10

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by gm10 »

trytip wrote: Thu Aug 16, 2018 6:31 pm @gm10
does the cpu use less % playing x264 compared to x265 ? i am curious about that. i know nothing about integrated graphics, my laptop is about 2 years old but haven't used it much with linux. the mpv config i posted is for stand alone nvidia graphic cards. hopefully the OP has a stand alone, didn't yet ask for inxi -Fxzd :D i'm guessing that would help
Seems mostly the same, HVEC slightly higher but probably within margin of error. Using the 4k sample files from https://x265.com/hevc-video-files/, output to a 1080p screen:

Code: Select all

$ sudo intel_gpu_time mpv BigBuckBunny_2000h264.mp4 -fs
Playing: BigBuckBunny_2000h264.mp4
 (+) Video --vid=1 (*) (h264 3840x2160 24.000fps)
Using hardware decoding (vaapi).
VO: [vaapi] 3840x2160 vaapi[nv12]
V: 00:00:10 / 00:00:10 (100%)


Exiting... (End of file)
user: 0.744147s, sys: 0.485461s, elapsed: 10.693023s, CPU: 11.5%, GPU: 14.5%

Code: Select all

$ sudo intel_gpu_time mpv BigBuckBunny_2000hevc.mp4 -fs
Playing: BigBuckBunny_2000hevc.mp4
 (+) Video --vid=1 (*) (hevc 3840x2160 24.000fps)
Using hardware decoding (vaapi).
VO: [vaapi] 3840x2160 vaapi[nv12]
V: 00:00:10 / 00:00:10 (100%)


Exiting... (End of file)
user: 0.987175s, sys: 0.395721s, elapsed: 10.667563s, CPU: 13.0%, GPU: 17.0%
This was with the browser running in the background. The HVEC version looks noticeably better by the way, guess the x264 needs much more bitrate to be presentable, so take this comparison with a grain of salt.
User avatar
trytip
Level 14
Level 14
Posts: 5366
Joined: Tue Jul 05, 2016 1:20 pm

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by trytip »

i'm not even able to play the x264 file of 4k . maybe the OP can test it and see if acceleration turns on or not. what i know is that if i use vo=vdpau i get framerate skipping. if i leave out the vo= what my gpu can play, it plays smooth. but i notice mpv is complaining about my compton compositor when playing .mp4 but not .mkv

so maybe vo=vdpau helps newer drivers ? OP will have to test that for himself i'll edit the mpv.conf to include vo= but put a comment in it
Image
gm10

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by gm10 »

trytip wrote: Thu Aug 16, 2018 9:07 pm if i leave out the vo= what my gpu can play, it plays smooth. but i notice mpv is complaining about my compton compositor when playing .mp4 but not .mkv
I can output to vdpau, no frames dropped, but with compton active I get the same message you are getting I assume. But obviously vdpau makes little sense on my intel platform so I get a warning about that:

Code: Select all

[vo/vdpau] VDPAU is most likely emulated via VA-API.
[vo/vdpau] This is inefficient. Use --vo=gpu instead.
VO: [vdpau] 3840x2160 yuv420p
[vo/vdpau] Compositing window manager detected. Assuming timing info is inaccurate.
On my platform I get best performance with the vaapi output driver. Somewhat surprisingly the default direct gpu renderer performs worse than even vdpau. That's why I have to set the vo= parameter in the config file. Also vaapi plays all formats, anyway. I know you guys are on nvidia, telling you just in case you got intel CPUs and want to try out your intel graphics.
User avatar
trytip
Level 14
Level 14
Posts: 5366
Joined: Tue Jul 05, 2016 1:20 pm

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by trytip »

i noticed --vo=gpu not sure this works with nvidia, can't get it working. try out the audio compressor yet? anyone can do this. great for low audio videos. parameters can be changed in the .lua default_makeup = 12.0,

install ffmpeg if you don't have it create
.config/mpv/scripts/
in scripts folder create blank text name it acompressor.lua once in mpv you can activate it with N
ps: if you use save-position-on-quit in mpv.conf delete files in .config/mpv/watch_later/ to refresh cookies

Code: Select all

-- This script adds control to the dynamic range compression ffmpeg
-- filter including key bindings for adjusting parameters.
--
-- See https://ffmpeg.org/ffmpeg-filters.html#acompressor for explanation
-- of the parameteres.

local mp = require 'mp'
local options = require 'mp.options'

local o = {
	default_enable = false,
	show_osd = true,
	osd_timeout = 4000,
	filter_label = mp.get_script_name(),

	key_toggle = 'n',
	key_increase_threshold = 'F1',
	key_decrease_threshold = 'Shift+F1',
	key_increase_ratio = 'F2',
	key_decrease_ratio = 'Shift+F2',
	key_increase_knee = 'F3',
	key_decrease_knee = 'Shift+F3',
	key_increase_makeup = 'F4',
	key_decrease_makeup = 'Shift+F4',
	key_increase_attack = 'F5',
	key_decrease_attack = 'Shift+F5',
	key_increase_release = 'F6',
	key_decrease_release = 'Shift+F6',

	default_threshold = -25.0,
	default_ratio = 3.0,
	default_knee = 2.0,
	default_makeup = 12.0,
	default_attack = 20.0,
	default_release = 250.0,

	step_threshold = -2.5,
	step_ratio = 1.0,
	step_knee = 1.0,
	step_makeup = 1.0,
	step_attack = 10.0,
	step_release = 10.0,
}
options.read_options(o)

local params = {
	{ name = 'attack',    min=0.01, max=2000, hide_default=true,  dB=''   },
	{ name = 'release',   min=0.01, max=9000, hide_default=true,  dB=''   },
	{ name = 'threshold', min= -30, max=   0, hide_default=false, dB='dB' },
	{ name = 'ratio',     min=   1, max=  20, hide_default=false, dB=''   },
	{ name = 'knee',      min=   1, max=  10, hide_default=true,  dB='dB' },
	{ name = 'makeup',    min=   0, max=  24, hide_default=false, dB='dB' },
}

local function parse_value(value)
	-- Using nil here because tonumber differs between lua 5.1 and 5.2 when parsing fractions in combination with explicit base argument set to 10.
	-- And we can't omit it because gsub returns 2 values which would get unpacked and cause more problems. Gotta love scripting languages.
	return tonumber(value:gsub('dB$', ''), nil)
end

local function format_value(value, dB)
	return string.format('%g%s', value, dB)
end

local function show_osd(filter)
	if not o.show_osd then
		return
	end

	if not filter.enabled then
		mp.commandv('show-text', 'Dynamic range compressor: disabled', o.osd_timeout)
		return
	end

	local pretty = {}
	for _,param in ipairs(params) do
		local value = parse_value(filter.params[param.name])
		if not (param.hide_default and value == o['default_' .. param.name]) then
			pretty[#pretty+1] = string.format('%s: %g%s', param.name:gsub("^%l", string.upper), value, param.dB)
		end
	end

	if #pretty == 0 then
		pretty = ''
	else
		pretty = '\n(' .. table.concat(pretty, ', ') .. ')'
	end

	mp.commandv('show-text', 'Dynamic range compressor: enabled' .. pretty, o.osd_timeout)
end

local function get_filter()
	local af = mp.get_property_native('af', {})

	for i = 1, #af do
		if af[i].label == o.filter_label then
			return af, i
		end
	end

	af[#af+1] = {
		name = 'acompressor',
		label = o.filter_label,
		enabled = false,
		params = {},
	}

	for _,param in pairs(params) do
		af[#af].params[param.name] = format_value(o['default_' .. param.name], param.dB)
	end

	return af, #af
end

local function toggle_acompressor()
	local af, i = get_filter().
	af[i].enabled = not af[i].enabled
	mp.set_property_native('af', af)
	show_osd(af[i])
end

local function update_param(name, increment)
	for _,param in pairs(params) do
		if param.name == string.lower(name) then
			local af, i = get_filter()
			local value = parse_value(af[i].params[param.name])
			value = math.max(param.min, math.min(value + increment, param.max))
			af[i].params[param.name] = format_value(value, param.dB)
			af[i].enabled = true
			mp.set_property_native('af', af)
			show_osd(af[i])
			return
		end
	end

	mp.msg.error('Unknown parameter "' .. name .. '"')
end

mp.add_key_binding(o.key_toggle, "toggle-acompressor", toggle_acompressor)
mp.register_script_message('update-param', update_param)

for _,param in pairs(params) do
	for direction,step in pairs({increase=1, decrease=-1}) do
		mp.add_key_binding(o['key_' .. direction .. '_' .. param.name],
		                   'acompressor-' .. direction .. '-' .. param.name,
		                   function() update_param(param.name, step*o['step_' .. param.name]); end,
		                   { repeatable = true })
	end
end

if o.default_enable then
	local af, i = get_filter()
	af[i].enabled = true
	mp.set_property_native('af', af)
end
Image
gm10

Re: How do I ensure Hardware Acceleration? I used to use VDPAU on a 8800, but now I have a GeForce GTX 460

Post by gm10 »

trytip wrote: Thu Aug 16, 2018 10:02 pm i noticed --vo=gpu not sure this works with nvidia, can't get it working. try out the audio compressor yet? anyone can do this. great for low audio videos. parameters can be changed in the .lua default_makeup = 12.0,
Depending on your mpv version you don't have a gpu output driver, you likely have opengl instead. As I mentioned above, you can run this to list all your available output drivers:

Code: Select all

mpv --vo=help
I have never played with the audio options, no, never felt the need.
Locked

Return to “Hardware Support”