summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2024-03-16 22:32:29 +0100
committerKacper Michajłow <kasper93@gmail.com>2024-03-21 02:40:00 +0100
commit2a08440afbe76548c583bd38ac9ae89300ed9d1d (patch)
tree2b35a4ea79b0ab8b061636bbf617efac9d67eaaa
parent0deefd80bf37a50de1ace518a3212de4b2a750fc (diff)
downloadmpv-2a08440afbe76548c583bd38ac9ae89300ed9d1d.tar.bz2
mpv-2a08440afbe76548c583bd38ac9ae89300ed9d1d.tar.xz
stats.lua: add more information in audio section
- current AO - AO device - AO volume - audio delay - output format
-rw-r--r--player/lua/stats.lua27
1 files changed, 21 insertions, 6 deletions
diff --git a/player/lua/stats.lua b/player/lua/stats.lua
index 75c3e35032..e004272bcb 100644
--- a/player/lua/stats.lua
+++ b/player/lua/stats.lua
@@ -950,19 +950,34 @@ end
local function add_audio(s)
local r = mp.get_property_native("audio-params")
-- in case of e.g. lavfi-complex there can be no input audio, only output
- if not r then
- r = mp.get_property_native("audio-out-params")
- end
+ local ro = mp.get_property_native("audio-out-params") or r
+ r = r or ro
if not r then
return
end
+ local merge = function(r, ro, prop)
+ local a = r[prop] or ro[prop]
+ local b = ro[prop] or r[prop]
+ return (a == b or a == nil) and a or (a .. " → " .. b)
+ end
+
append(s, "", {prefix=o.nl .. o.nl .. "Audio:", nl="", indent=""})
append_property(s, "audio-codec", {prefix_sep="", nl="", indent=""})
- local cc = append(s, r["channel-count"], {prefix="Channels:"})
- append(s, r["format"], {prefix="Format:", nl=cc and "" or o.nl,
+ append_property(s, "current-ao", {prefix="AO:", nl="",
+ indent=o.prefix_sep .. o.prefix_sep})
+ local dev = append_property(s, "audio-device", {prefix="Device:"})
+ local ao_mute = mp.get_property_native("ao-mute") and " (Muted)" or ""
+ append_property(s, "ao-volume", {prefix="AO Volume:", suffix="%" .. ao_mute,
+ nl=dev and "" or o.nl,
+ indent=dev and o.prefix_sep .. o.prefix_sep})
+ if math.abs(mp.get_property_native("audio-delay")) > 1e-6 then
+ append_property(s, "audio-delay", {prefix="A-V delay:"})
+ end
+ local cc = append(s, merge(r, ro, "channel-count"), {prefix="Channels:"})
+ append(s, merge(r, ro, "format"), {prefix="Format:", nl=cc and "" or o.nl,
indent=cc and o.prefix_sep .. o.prefix_sep})
- append(s, r["samplerate"], {prefix="Sample Rate:", suffix=" Hz"})
+ append(s, merge(r, ro, "samplerate"), {prefix="Sample Rate:", suffix=" Hz"})
append_property(s, "packet-audio-bitrate", {prefix="Bitrate:", suffix=" kbps"})
append_filters(s, "af", "Filters:")
end