Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
remix surround channel levels
cmCenter = 1
local defCenter = 1
cmFront = 0.707
local defFront = 0.707
cmSide = 0.707
local defSide = 0.707
cmBack = 0.707
local defBack = 0.707
cmLFE = 0
local defLFE = 0
local function mix(channel, adjustment)
if channel == "reset" then
cmCenter = defCenter
cmFront = defFront
cmSide = defSide
cmBack = defBack
cmLFE = defLFE
_G[channel] = _G[channel] + adjustment
if _G[channel] < 0.001 then _G[channel] = 0 end
mp.set_property("af", "lavfi=[pan=stereo|FL="..cmCenter.."FC+"..cmFront.."FL+"..cmSide.."SL+"..cmBack.."BL+"..cmLFE.."LFE|FR="..cmCenter.."FC+"..cmFront.."FR+"..cmSide.."SR+"..cmBack.."BR+"..cmLFE.."LFE]")
mp.osd_message("lavfi=[pan=stereo|\nFL="..cmCenter.."FC+"..cmFront.."FL+"..cmSide.."SL+"..cmBack.."BL+"..cmLFE.."LFE|\nFR="..cmCenter.."FC+"..cmFront.."FR+"..cmSide.."SR+"..cmBack.."BR+"..cmLFE.."LFE]", 5)
mp.add_key_binding("Ctrl+Shift+F8", "mReset", function() mix("reset") end)
mp.add_key_binding("Shift+F8", "cUp", function() mix("cmCenter",0.1) end)
mp.add_key_binding("Ctrl+F8", "cDown", function() mix("cmCenter",-0.1) end)
mp.add_key_binding("Shift+F9", "fUp", function() mix("cmFront",0.1) end)
mp.add_key_binding("Ctrl+F9", "fDown", function() mix("cmFront",-0.1) end)
mp.add_key_binding("Shift+F10", "sUp", function() mix("cmSide",0.1) end)
mp.add_key_binding("Ctrl+F10", "sDown", function() mix("cmSide",-0.1) end)
mp.add_key_binding("Shift+F11", "bUp", function() mix("cmBack",0.1) end)
mp.add_key_binding("Ctrl+F11", "bDown", function() mix("cmBack",-0.1) end)
mp.add_key_binding("Shift+F12", "lUp", function() mix("cmLFE",0.1) end)
mp.add_key_binding("Ctrl+F12", "lDown", function() mix("cmLFE",-0.1) end)
Copy link

Using a modifier (Shift or Ctrl) and the function keys (F8-F12) you can adjust the mixing level of surround channels on the fly
Ctrl+Shift+F8 resets the levels to ffmpeg defaults

Copy link

F8 adjusts the center channel
F9 adjusts the front channel
F10 adjusts the side channel
F11 adjusts the back channel
F12 adjusts the LFE channel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment