Skip to content

Instantly share code, notes, and snippets.

@bitingsock
Created June 12, 2019 09:12
Show Gist options
  • Save bitingsock/1e7ef04a151963b38e347a723d7e3201 to your computer and use it in GitHub Desktop.
Save bitingsock/1e7ef04a151963b38e347a723d7e3201 to your computer and use it in GitHub Desktop.
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
else
_G[channel] = _G[channel] + adjustment
if _G[channel] < 0.001 then _G[channel] = 0 end
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)
end
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)
@bitingsock
Copy link
Author

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

@bitingsock
Copy link
Author

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