[Extension] Force Aspect Ratio

Discuss your Lua playlist, album art and interface scripts.
mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

[Extension] Force Aspect Ratio

Postby mederi » 16 Jul 2013 17:01

Please test the extension:

Code: Select all

-- "force aspect ratio.lua" -- VLC Extension aspect_ratio = "16:9" -- "" for default AR function descriptor() return { title = "Force Aspect Ratio", version = "1.0", capabilities = {"meta-listener"} } end function activate() Set_AR(aspect_ratio) end function deactivate() Set_AR("") end function meta_changed() Set_AR(aspect_ratio) end function Set_AR(ar) local vout=vlc.object.vout() if vout then vlc.var.set(vout,"aspect-ratio",ar) end end

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Extension: Force Aspect Ratio

Postby mederi » 17 Jul 2013 16:01

It takes "Integer:Integer" values, so "221:100" instead of "2.21:1".
Added simple dialog box with all available predefined aspect ratios:

Code: Select all

-- "force aspect ratio.lua" -- VLC Extension --[[ Changelog: (1.1) * Simple dialog box with drop-down list of aspect ratios and APPLY button; * OSD message; (1.0) * Initial release; --]] aspect_ratio = "" -- "Integer:Integer"; "" for default AR aspect_ratios = {"","1:1","5:4","4:3","16:10","16:9","221:100","235:100","239:100"} function descriptor() return { title = "Force Aspect Ratio", version = "1.1", capabilities = {"meta-listener"} } end function activate() Create_dialog() Set_AR(aspect_ratio) end function deactivate() Set_AR("") end function meta_changed() Set_AR(aspect_ratio) end function Set_AR(ar) local vout=vlc.object.vout() if vout then vlc.var.set(vout,"aspect-ratio",ar) if not channel1 then channel1 = vlc.osd.channel_register() end vlc.osd.message(ar,channel1) end end --- Dialog box --- function close() vlc.deactivate() end function Create_dialog() w = vlc.dialog(descriptor().title .. " (" .. descriptor().version ..")") w1 = w:add_dropdown(1, 1) for i,v in ipairs(aspect_ratios) do w1:add_value(v, i) end w2 = w:add_button("APPLY", click_APPLY, 2, 1) end function click_APPLY() aspect_ratio = w1:get_text() Set_AR(aspect_ratio) end
Tip: use keyboard down/up arrow keys and enter in the dialog box


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 8 guests