Force audio channel by title metadata

Discuss your Lua playlist, album art and interface scripts.
Bobby561
New Cone
New Cone
Posts: 1
Joined: 08 Nov 2023 14:04

Force audio channel by title metadata

Postby Bobby561 » 08 Nov 2023 14:12

Hello,

I have lots of video with multiple audio channel, two in french and one in english. Right now, when I set VLC to play FR by default in the setting it will play the first to be French.

But the first French one is Quebec version, and I would like to play by default the France version.

They have for title "VFF" for France and "VFQ" for Quebec.

I tried to make a script to automatically play the VFF titled one but it doesn't seem to work, I can't even seem to trigger the callback when I change video.

https://pastebin.com/raw/YRxTy3he

Code: Select all

function descriptor() return { title = "VLC Extension - Basic structure", version = "1.0", author = "", shortdesc = "short description", description = "full description", capabilities = {"input-listener"} } end function activate() create_dialog() end function input_changed() vlc.msg.info("playing_changed") local input = vlc.object.input() if input then local audio_tracks = vlc.input.item():metas()["input-es"] vlc.msg.info("Total audio streams found: " .. #audio_tracks) for i, track in pairs(audio_tracks) do vlc.msg.info("Audio stream " .. i .. " title: " .. track["title"]) if track["title"] == "VFF" then vlc.var.set(input, "audio-es", i - 1) vlc.msg.info("Selected the 'VFF' audio stream.") break end end end } greeting = "Welcome!<br />" -- example of global variable function create_dialog() w = vlc.dialog("VLC Extension - Dialog box example") w1 = w:add_text_input("Hello world!", 1, 1, 3, 1) w2 = w:add_html(greeting, 1, 2, 3, 1) w3 = w:add_button("Action!",click_Action, 1, 3, 1, 1) w4 = w:add_button("Clear",click_Clear, 2, 3, 1, 1) end function click_Action() local input_string = w1:get_text() -- local variable local output_string = w2:get_text() .. input_string .. "<br />" --w1:set_text("") w2:set_text(output_string) end function click_Clear() w2:set_text("") end
I'm really not used to VLC api, and not getting any output in the vlc message is even harder to understand how it work

Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 5 guests