[Extension] Fine adjust playback speed

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] Fine adjust playback speed

Postby mederi » 18 Feb 2017 18:38

The idea: https://forum.videolan.org/viewtopic.ph ... 21#p453521

Code: Select all

function descriptor() return { title = "Fine adjust playback speed", capabilities = {"meta-listener"} } end function activate() Create_dialog() click_Rate(0) end function deactivate() end function meta_changed() click_Rate(0) end --- Dialog box --- function close() vlc.deactivate() end function Create_dialog() d = vlc.dialog(descriptor().title) ti_step = d:add_text_input("0.01",1,1,2,1) d:add_button("<<", function() click_Rate(-1) end, 1,2,1,1) d:add_button(">>", function() click_Rate(1) end, 2,2,1,1) end rate=1 function click_Rate(dir) local input=vlc.object.input() if input then rate=rate+dir*tonumber(ti_step:get_text()) vlc.var.set(input, "rate", rate) -- crate=vlc.var.get(input,"rate") d:set_title(rate .. " (" .. crate .. ")") end end

verdigris
Blank Cone
Blank Cone
Posts: 20
Joined: 10 Feb 2017 11:08

Re: [Extension] Fine adjust playback speed

Postby verdigris » 19 Feb 2017 15:51

Very kind. What do I have to do to use it?

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] Fine adjust playback speed

Postby mederi » 19 Feb 2017 17:32

Copy/paste the code, save the file as "faps.lua" into "\lua\extensions\" folder, restart VLC. Then activate the extension in VLC menu: View > Fine adjust playback speed. More extensions and installation instructions at https://addons.videolan.org

verdigris
Blank Cone
Blank Cone
Posts: 20
Joined: 10 Feb 2017 11:08

Re: [Extension] Fine adjust playback speed

Postby verdigris » 19 Feb 2017 17:35

:D

I can't find a way to "like" posts on this forum, but take that as one.

verdigris
Blank Cone
Blank Cone
Posts: 20
Joined: 10 Feb 2017 11:08

Re: [Extension] Fine adjust playback speed

Postby verdigris » 19 Feb 2017 19:53

This is great, thank you very much (which is not to say I wouldn't still like the features requested here: https://forum.videolan.org/viewtopic.php?f=7&t=137509 ).

I can't pretend to understand all the details, and never even heard of Lua before, but working on what you've given me I have made a few tweaks:

1. There is now a normal speed button between the slower and faster buttons, and the labelling is more explicit;

2. The tool title bar now shows "Speed = 1.00" when the rate is normal speed, rather than the cryptic "1(1)";

3. I have renamed it "Pop-Out Playback Speed Control" (and the file is ppsc.lua).

There is one thing that eludes me: I tried to make it reset the playback speed to 1.00 if the tool is closed (as you will see - by putting "vlc.var.set(input, "rate", 1)" in the deactivate function), but it doesn't work (neither does it work if the line is put in the close function). Any ideas?

Code: Select all

function descriptor() return { title = "Pop-Out Playback Speed Control", capabilities = {"meta-listener"} } end function activate() Create_dialog() click_Rate(0) end function deactivate() vlc.var.set(input, "rate", 1) end function meta_changed() click_Rate(0) end --- Dialog box --- function close() vlc.deactivate() end function Create_dialog() d = vlc.dialog(descriptor().title) d:add_label("+/- Step Size:",1,1,1,1) ti_step = d:add_text_input("0.01",2,1,2,1) d:add_button("<< Slower", function() click_Rate(-1) end, 1,2,1,1) d:add_button("Normal (1.00)", function() click_Rate(0) end, 2,2,1,1) d:add_button("Faster >>", function() click_Rate(1) end, 3,2,1,1) end rate=1 function click_Rate(dir) local input=vlc.object.input() if input then if dir==0 then rate=1 else rate=rate+dir*tonumber(ti_step:get_text()) end vlc.var.set(input, "rate", rate) -- crate=vlc.var.get(input,"rate") if rate==1 then d:set_title("Speed = 1.00") else d:set_title("Speed = " .. rate .. " (" .. crate .. ")") end 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] Fine adjust playback speed

Postby mederi » 20 Feb 2017 17:10

I have used click_Rate(0) within meta_changed() callback function to set the current speed also for next item in playlist. Now it always resets the rate to normal speed (1).

Code: Select all

-- local variable: local input=vlc.object.input() -- global variable: input=vlc.object.input() -- or simply: vlc.var.set(vlc.object.input(), "rate", 1)

verdigris
Blank Cone
Blank Cone
Posts: 20
Joined: 10 Feb 2017 11:08

Re: [Extension] Fine adjust playback speed

Postby verdigris » 19 Mar 2017 09:28

Just a comment, but I wonder whether anybody can shed light:

1. With the extension running, the standard playback speed control is no longer functional;

2. Double-clicking the standard playback speed indicator crashes VLC.

drold
New Cone
New Cone
Posts: 2
Joined: 28 Oct 2016 20:45

Re: [Extension] Fine adjust playback speed

Postby drold » 23 Apr 2017 01:44

Why did VLC get rid of the previous method of speed control????

It worked. I could use the keyboard to increase the speed.

That's one of the main reasons I use VLC so I can use to SPEED videos.

This video speed controler is SLOW to adjust.

There are no keys on the key board that work to speed it up.

Seriously???? Why do programs get worse and worse NOT better!

I mean EVERY PROGRAM GETS WORSE AND WORSE!!!!!

Microsoft word I still can't control a TABLE!

Excel could be a million times easier.

Get it together programmers!!!!! SERIOUSLY!!!!!

Make thing intuitive but STOP getting rid of BASIC FUNCTIONS!!!!!!

verdigris
Blank Cone
Blank Cone
Posts: 20
Joined: 10 Feb 2017 11:08

Re: [Extension] Fine adjust playback speed

Postby verdigris » 03 May 2017 09:09

There are better places to post that kind of rant. This topic is about developing a fine speed control extension, not complaining about the standard function.

DanceCatDave
New Cone
New Cone
Posts: 3
Joined: 28 Jun 2017 16:38

Re: [Extension] Fine adjust playback speed

Postby DanceCatDave » 30 Jun 2017 18:40

Hey folks,

Rank noob here, and not sure where to post.

I'm an amateur DJ and use software for my music (Traktor, specifically). I also have a number of videos of light effects, animals "dancing", etc. I would like to combine the two, using VLC.

My thought is this: Computer 1 will output the music to the mixer, as well as to Computer 2. Computer 2 will read the BPM of the current song (based on MIDI information, for example), and automatically adjust the VLC playback speed to match.

For example, I have a video of a bird bopping its head at 100 BPM. When I play a song that is 108 BPM, I'd like the information to automatically adjust the playback speed up to 1.08 (assuming that "1.08" represents a 100-point graduation speed increase, as opposed to some other standard). I would also like it to "beat-match", if at all possible. That way the head isn't bopping at a 1/3 beat off of the music.

Has this already been done? CAN this be done?

Once I have the information, I can have someone write the script (or whatever), since everything I know about computing can fit in the word "nothing".

The information on getting MIDI out of Traktor is here, if that makes a difference.

https://support.native-instruments.com/ ... in-TRAKTOR

Thanks

verdigris
Blank Cone
Blank Cone
Posts: 20
Joined: 10 Feb 2017 11:08

Re: [Extension] Fine adjust playback speed

Postby verdigris » 30 Jun 2017 23:27

Off topic. Start a new thread.

jfhenault
New Cone
New Cone
Posts: 6
Joined: 08 Oct 2017 02:04

Re: [Extension] Fine adjust playback speed

Postby jfhenault » 24 Feb 2018 18:51

Does someone know how to implement/use hotkeys from this LUA file? It would be great to change speed rate with ultra fine precision without opening/clicking this extension all the time in Menu/View. Maybe this LUA extension with hotkeys support that loads automatically with VLC.

Is it possible?

And another thing : Is there a way to center the text in the textbox?

jfhenault
New Cone
New Cone
Posts: 6
Joined: 08 Oct 2017 02:04

Re: [Extension] Fine adjust playback speed

Postby jfhenault » 24 Feb 2018 20:40

For those who know programming better than me, maybe this link could help.

https://forum.videolan.org/viewtopic.php?t=111880

As I said, it would be great to add hotkeys to this extension but also to load the extension anytime VLC is launched so we could change speed rate with ultra precision using hotkeys. A hotkey could also open a popup window only to specify the incrementation (e.g. 0.01x).

Thank you!!

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] Fine adjust playback speed

Postby mederi » 25 Feb 2018 13:51

No, hotkeys are not supported in plugins/addons in latest VLC. Old VLC 2.0.x supports callbacks (including hotkeys) in Lua scripts. Automatic activation of Extensions has not been implemented yet. Qt GUI (Windows, Linux) supports button hotkeys within dialog box (ampersand character somewhere in button label string => Alt+key).

gdeangel
New Cone
New Cone
Posts: 2
Joined: 18 Aug 2019 05:22

Re: [Extension] Fine adjust playback speed

Postby gdeangel » 19 Aug 2019 01:33

Why did VLC get rid of the previous method of speed control????

It worked. I could use the keyboard to increase the speed.

...

Make thing intuitive but STOP getting rid of BASIC FUNCTIONS!!!!!!
I will give you my guess... because somewhere in the development process some code for the keyboard shortcuts got broken. My version of VLC will *sometimes* recognize the hotkeys ([ and ]), and sometimes not. That smacks of something other than intentional feature deprecation.

But what I really wanted to ask here is can this extension be used in a playlist to adjust playback speeds automatically?

verdigris
Blank Cone
Blank Cone
Posts: 20
Joined: 10 Feb 2017 11:08

Re: [Extension] Fine adjust playback speed

Postby verdigris » 19 Aug 2019 08:47

But what I really wanted to ask here is can this extension be used in a playlist to adjust playback speeds automatically?
That would be very nice, although you would need some way to store the adjustment factor alongside the track in the playlist and I'm not at all sure the standard for playlists will accommodate that - or, if it does, whether VLC's implementation can.

An alternative might be to store the preset speed adjustment in an MP3 tag, but again you would then need to persuade VLC to read the tag and act on it.

My opinion is that this is all too difficult for VLC and would need a bespoke MP3 player with that kind of functionality in mind from the ground up.

nickyg
New Cone
New Cone
Posts: 1
Joined: 31 Oct 2020 12:57

Re: [Extension] Fine adjust playback speed

Postby nickyg » 16 Jan 2021 15:27

it's a great extension it just lacks one thing to make it fantastic: the ability to control the << Slower | keys Faster >> with keyboard commands keeping the panel closed.
As VLC natively works, only VLC does not allow you to manually set the speed hops.


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 11 guests