Timestamps via Button click

For questions and discussion that is NOT (I repeat NOT) specific to a certain Operating System.
Byrth
New Cone
New Cone
Posts: 3
Joined: 01 Feb 2016 22:25

Timestamps via Button click

Postby Byrth » 01 Feb 2016 22:31

I am using VLC to analyze behavioral data and need to record the timestamp when events occur. Currently I have to pause the video, tab over to Microsoft Excel, and type in the new time, then tab back and hit play again. This, combined with the tedium of the method, causes analysis to take approximately 4x longer than it theoretically could take, which is bad when I generate 1.5 hours of data each day.

Is there a way that I can use VLC's scripting to make a button that adds the current timestamp to a table, which I then could view and copy into excel? Making a bookmark would also be sufficient, and then I could just copy the bookmark list into excel by hand (still much faster).

This solution would ideally be OS agnostic, but I'm on a Mac if it matters. I do have some experience with Lua.

Thanks for any replies!


Etoh
Blank Cone
Blank Cone
Posts: 60
Joined: 12 Jan 2013 16:33

Re: Timestamps via Button click

Postby Etoh » 02 Feb 2016 00:40

Or, if you want to avoid add-ons, you could just take a screenshot (Shift+S) every time you want to save time.

Byrth
New Cone
New Cone
Posts: 3
Joined: 01 Feb 2016 22:25

Re: Timestamps via Button click

Postby Byrth » 17 Feb 2016 21:00

Okay, came back to this. elapsed_time_to_file was pretty close to what I wanted. I modified it to be this:

Code: Select all

-- "eplased_time_to_file.lua" -- VLC Extension script -- [ Global variables ] -- blue_hotkey=98 -- b key orange_hotkey=111 -- o key -------------------------- function descriptor() return { title = "eps_time", version = "1.0", author = "valuex, modified by Byrth", url = "...", shortdesc = "save eplased time to file.", description = "save eplased time to file by hotkey" } end function activate() blue_file=vlc.misc.userdatadir().."/blue_time_log.txt" --time log file path blue_counter = 0 orange_file=vlc.misc.userdatadir().."/orange_time_log.txt" --time log file path orange_counter = 0 vlc.var.add_callback( vlc.object.libvlc(), "key-pressed", key_press ) end function deactivate() vlc.var.del_callback( vlc.object.libvlc(), "key-pressed", key_press ) end function close() vlc.deactivate() end function key_press( var, old, new, data ) --do some thing if new==blue_hotkey then elapsed_time_to_file(blue_file,blue_counter) blue_counter = blue_counter +1 elseif new==orange_hotkey then elapsed_time_to_file(orange_file,orange_counter) orange_counter = orange_counter +1 end end function elapsed_time_to_file(datafile,counter) local input = vlc.object.input() local curtime=vlc.var.get(input, "time") io.output(datafile) if counter%2 = 1 then io.write(', ') else io.write('\r\n') end io.write(curtime) io.close() end
I have three pretty basic questions that I can't get around and can't seem to find the answer to:
1) How do I get it to print anything to the debugging log? I can't debug it at the moment.
2) After half an hour on google, I finally got the addon to show up in Addon manager (secret was to make a %appdata%/vlc/lua/extensions/ folder and put it inside). Is seeing it in addon manager enough? Is the script running?
3) Where is vlc.misc.userdatadir()?

Byrth
New Cone
New Cone
Posts: 3
Joined: 01 Feb 2016 22:25

Re: Timestamps via Button click

Postby Byrth » 17 Feb 2016 21:57

Sorry to double-post, but I figured out some of the answers:

1) View->Messages-> Change level to debug 2, use vlc.msg.info(string) to print to the log

2) The answer is that it wasn't, because there was an error that I couldn't find without a debug log (I used = instead of == in comparison)

3) vlc.misc no longer exists, and a brief attempt to re-locate this in the vlc table was not fruitful.

Additionally, I discovered that button callbacks were removed per this thread: https://trac.videolan.org/vlc/ticket/8097

It looks like the Lua API for VLC is at best undocumented and at worst unmaintained. Maybe there should be some kind of a warning to that effect.

giannife
New Cone
New Cone
Posts: 3
Joined: 15 May 2020 12:18

Re: Timestamps via Button click

Postby giannife » 15 May 2020 13:15

Can you post the final version of your script? Does it work with vlc 3? It seems that some calls are possibly incompatible.
Thanks for any suggestion


Return to “General VLC media player Troubleshooting”

Who is online

Users browsing this forum: No registered users and 14 guests