mpv
mpv copied to clipboard
Add a way to play multiple audio tracks at once without the need of the launch option
Expected behavior of the wanted feature
Be able to select which tracks to play (multiple) without the use of the command line, a lua script would also work if anyone knows one that allows this that would also solve my issue. Essentially, a script or functionality that implements the "--lavfi-complex='[aid1] [aid2] amix [ao]'" launch option into the gui of mpv. I need to be able to select different tracks depending on the situation, so like track one playing simultaneously with track 4 for example.
Alternative behavior of the wanted feature
None
Log file
Not needed
I know, but this feature would be incredibly useful when there are multiple tracks, and afaik there are no other video players that can currently do this.
Another solution could be a lua which would hopefully allow me to select 1 or multiple tracks (maybe with keybinding numbers) to play concurrently. Unfortunately I don't know anything about lua so I wouldn't be able to make this script, but if anyone with lua knowledge reads this and decides to make one (or if one's already been made) I would be very thankful.
- An example implement by the childprocess audio-dupe.lua
- Another crappy solution I use currently. You may have to modify those osd msg to match your language. https://github.com/hooke007/MPV_lazy/commit/fcd73b63eeae07d355058ec0baa5275ac38acd0d
@hooke007 Trying to use the second one, little bit confused on what to do. Translated the necessary parts to English but pressing function keys does nothing. Anyways, back to the main topic, would something like this be possible to make in a lua script with a clickable gui? If so I might learn lua and see what I can do.
After loading the file containing 2 or more audiotracks, 1.switch to the aid1 first and then activate keybind1 2.switch to the aid2 first and then activate keybind2, 3.now you could activate keybind3 to play the aid1&2 at the same time
would something like this be possible to make in a lua script with a clickable gui?
It should be possible. Ref an interactive filebrowser https://github.com/CogentRedTester/mpv-file-browser/issues/22
Unfortunately I'm still unable to do that, after I press the buttons nothing happens. I think that's a little off topic though, is there another place I can message you? (like discord) or I can just use the issue tracker on your repository of that, whichever you'd prefer. Also, I think I'm gonna try to learn lua if I can. I'm gonna leave this thread open for all of tomorrow (20th) just in case anyone else has an idea on what to do. I'll close it after that.
nothing happens
If you could not even receive any osd msg, maybe there was sth wrong in your modified script.
the issue tracker on your repository of that
Of course you can.
I don't know if you're still looking for a solution to this, but I threw together a quick script that allows you to select multiple tracks for mixing in an interactive list using the arrow keys and ENTER. You'll need to download mpv-scroll-list as well.
It's extremely unpolished, I threw it together in 30 mins, but it's better than nothing. I don't plan to spend any more time on it.
--[[
A horribly written script to change the audio tracks for `-lavfi-complex='[aid1] [aid2] amix [ao]'` at runtime
requires mpv-scroll-list: https://github.com/CogentRedTester/mpv-scroll-list
Open the browser with `N`
Select tracks with `ENTER`
Once two tracks are selected select again to undo the audio mix
]]
local mp = require "mp"
package.path = mp.command_native({"expand-path", "~~/script-modules/?.lua;"}) .. package.path
local list = require "scroll-list"
list.header = "Select multiple audio tracks:\\N------------------------------------------------"
-- updates the list with the current audio tracks
function update_tracks(tracks)
list.list = {}
for _, track in ipairs(tracks or mp.get_property_native("track-list")) do
if track.type == "audio" then
table.insert(list.list, {
id = track.id,
ass = ("{\\c&H%s&}aid%d: [%s] %s"):format(
track.selected and "33ff66" or "ffffff",
track.id, track.lang, track.title or "")
})
end
end
end
mp.observe_property('track-list', 'native', function(_, tracks) update_tracks(tracks) end)
mp.observe_property("aid", "number", function()
update_tracks()
list:update()
end)
-- selects the tracks when ENTER is used on the list
function select_track()
local track_1 = mp.get_property_number("aid")
local track_2 = list.__current.id
-- disables lavfi if it is already set
if mp.get_property("lavfi-complex", "") ~= "" then
mp.set_property("lavfi-complex", "")
mp.set_property_number("aid", track_2)
else
if not track_1 or not track_2 then return end
mp.set_property("lavfi-complex", ("[aid%d] [aid%d] amix [ao]"):format(track_1, track_2))
end
update_tracks()
list:update()
end
table.insert(list.keybinds, {"ENTER", "select", select_track})
mp.add_key_binding("n", "multi-ao-browser", function() list:toggle() end)
The Script provided by @CogentRedTester works almost perfectly but there's no way to enable more than 2 Is that because of technical limitations? If not is there a version out there that can enable more than 2?