[Extension] Time

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

Re: [Extension] Time

Postby mederi » 06 Mar 2020 13:54

Then it should be optional: classic time vs time recalculated by a speed rate. Some users could prefer standard elapsed time even at different playback speed. Meanwhile you can help yourself. Edit the "time_intf.lua" of Time v3.2:
elapsed_time = TIME_Time2string(elapsed_time, 0, not TIME_Enoms)
elapsed_time = TIME_Time2string(elapsed_time/rate, 0, not TIME_Enoms)
Similarly the remaining_time.

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

Re: [Extension] Time

Postby giannife » 15 May 2020 12:20

Hello, is there any chance that you could add some functionalities to this extension? I'm looking for a way to save the elapsed time to a log file, with a shortcut press. All the addons that I've found don't work anymore. Thanks

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] Time

Postby mederi » 16 May 2020 15:13

I am sorry, there are no hotkeys available in scripts.

Swishy27
New Cone
New Cone
Posts: 5
Joined: 22 May 2020 07:03

Re: [Extension] Time

Postby Swishy27 » 23 May 2020 16:41

Love your script and use it all the time when going through instructional videos to better manage my study time.

However, I am not too fond of the 24 hours format for the "[T] actual time" or "[O] time when video will be over". Can anyone show me where in the script I can edit to display the "actual time" and "time when video will be over" in order to display the time in 12 hour (AM/PM) format instead of the current 24 hour format?

Or better yet, add the option to display the time in 24 hour or 12 hour format?

I am currently using version 3.2.

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] Time

Postby mederi » 24 May 2020 17:19

I can show you, how to format T time. Edit the "time_intf.lua" file in a text editor. Find the line:
system_time = string.format(...

Code: Select all

system_time = string.format((TIME_Thm and "%02d:%02d" or "%02d:%02d:%02d") , (systemTime.hour<13 and systemTime.hour or systemTime.hour%12), systemTime.min, systemTime.sec)..(systemTime.hour<12 and "a" or "p")
The O time would be more complicated to do as it is formatted within general TIME_Time2string() function. ending_time = TIME_Time2string(...

Swishy27
New Cone
New Cone
Posts: 5
Joined: 22 May 2020 07:03

Re: [Extension] Time

Postby Swishy27 » 24 May 2020 18:50

@mederi,

Thanks for the assist. I updated the [T} time to AM/PM format as you instructed. Sweet.

Image

I'm not sure how difficult it would be to add another checkbox to the options panel, but it would be nice to be able to easily switch between 12hr or 24hr format for both [T] and [O]. Similar to the checkboxes to display milliseconds and [T] in h:m format.

Image

In the mean time, @mederi, If you figure out how to convert the [O] time to 12hr format as well, please pass it along. It would be greatly appreciated.

But for now, 1 out of 2 isn't bad.

Thanks again.

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] Time

Postby mederi » 25 May 2020 13:10

The O time string can be reprocessed.

Code: Select all

ending_time = TIME_Time2string(ending_time, 0, nil, TIME_Thm) -- h:m > D/h:m -- 12-hour format local h=tonumber(string.match(ending_time,"(%d%d):")) ending_time = string.gsub(ending_time, "%d%d:", string.format("%02d:", (h<13 and h or h%12)), 1)..(h<12 and "a" or "p")
I can add the "[T] 12hr" checkbox in the future. USA?

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] Time

Postby mederi » 25 May 2020 17:27

or

Code: Select all

ending_time = TIME_Time2string(ending_time, 0, nil, TIME_Thm) -- h:m > D/h:m -- 12-hour format local t = os.time({year=1970, month=1, day=1, hour=tonumber(string.match(ending_time,"(%d%d):")), min=0, sec=0}) local hh = os.date("%I", t) local ampm = os.date("%p", t) ending_time = string.gsub(ending_time, "%d%d:", hh..":", 1)..ampm

Swishy27
New Cone
New Cone
Posts: 5
Joined: 22 May 2020 07:03

Re: [Extension] Time

Postby Swishy27 » 25 May 2020 17:55

@mederi,

Awesome! Thank you very much for the quick solution(s). The update your provided below works great.

Image

I'll keep an eye out for the update with the check box.

Yes, USA.

Thank You

The O time string can be reprocessed.

Code: Select all

ending_time = TIME_Time2string(ending_time, 0, nil, TIME_Thm) -- h:m > D/h:m -- 12-hour format local h=tonumber(string.match(ending_time,"(%d%d):")) ending_time = string.gsub(ending_time, "%d%d:", string.format("%02d:", (h<13 and h or h%12)), 1)..(h<12 and "a" or "p")
I can add the "[T] 12hr" checkbox in the future. USA?

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] Time

Postby mederi » 26 May 2020 20:22

AM/PM works and so the Crew Dragon Demo-2 Mission can succeed tomorrow. Good luck. :)

Swishy27
New Cone
New Cone
Posts: 5
Joined: 22 May 2020 07:03

Re: [Extension] Time

Postby Swishy27 » 26 May 2020 21:37

@ Mederi,

Thanks a million for all your help. I did make an observation last night after revising the script with the recent updates you provided.

Late last night I noticed that "12:00 AM" was appearing as "00:00 AM" for both the "[T] actual time" and "[O] time when video will be over".

After noticing the "00:00 AM" time display at midnight, I updated the script with your most recent update (quoted below) for "[O] time when video will be over". As expected the script update correctly formatted the time to display as "12:00 AM" instead of "00:00 AM".
or

Code: Select all

ending_time = TIME_Time2string(ending_time, 0, nil, TIME_Thm) -- h:m > D/h:m -- 12-hour format local t = os.time({year=1970, month=1, day=1, hour=tonumber(string.match(ending_time,"(%d%d):")), min=0, sec=0}) local hh = os.date("%I", t) local ampm = os.date("%p", t) ending_time = string.gsub(ending_time, "%d%d:", hh..":", 1)..ampm
But the previous update to format "[T] actual time" doesn't seem to account for midnight and still displays as "00:00 AM" instead of "12:00 AM".
I can show you, how to format T time. Edit the "time_intf.lua" file in a text editor. Find the line:
system_time = string.format(...

Code: Select all

system_time = string.format((TIME_Thm and "%02d:%02d" or "%02d:%02d:%02d") , (systemTime.hour<13 and systemTime.hour or systemTime.hour%12), systemTime.min, systemTime.sec)..(systemTime.hour<12 and "a" or "p")
The O time would be more complicated to do as it is formatted within general TIME_Time2string() function. ending_time = TIME_Time2string(...
I tried to update the script to format the "[T] actual time" as "12:00 AM" instead of "00:00 AM", but no dice.

"[O] time when video will be over" as it appears before 12:00 AM

Image

"[T] actual time" as it appears after 12:00 AM

Image

Not a big deal since it only affects 1 hour out of the day, but I wanted to provide feedback for any future updates of the script with an AM/PM check box.

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] Time

Postby mederi » 27 May 2020 15:24

Then it is necessary to add a condition for 0 hour:

Code: Select all

system_time = string.format((TIME_Thm and "%02d:%02d" or "%02d:%02d:%02d") , (systemTime.hour<13 and (systemTime.hour>0 and systemTime.hour or 12) or systemTime.hour%12), systemTime.min, systemTime.sec)..(systemTime.hour<12 and "a" or "p")
or

Code: Select all

local t = os.time({year=1970, month=1, day=1, hour=systemTime.hour, min=0, sec=0}) local hh = os.date("%I", t) local ampm = os.date("%p", t) system_time = string.format((TIME_Thm and "%02d:%02d" or "%02d:%02d:%02d") , hh, systemTime.min, systemTime.sec)..ampm
The O time greater than 24 hours contains the counter of days D/... (next 1 day, next D days).

Swishy27
New Cone
New Cone
Posts: 5
Joined: 22 May 2020 07:03

Re: [Extension] Time

Postby Swishy27 » 28 May 2020 06:28

@mederi,

Success! The updates are working perfectly.

Image

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] Time

Postby mederi » 07 Sep 2020 13:44

Just to not leave behind a useful piece of code:
dementia

1 year ago
Updated code- 1) Detects the currently playing video stream used to determine the FPS. 2) changed variable from "fps" to "vlc_fps" so as not to clobber an existing variable. The following code goes directly above the line

"local osd_output = string.gsub(TIME_time_format, "%[E%]", elapsed_time)"

local input_object_info = vlc.input.item():info()
local key
local value
local vlc_fps
local cur_stream_name = "Stream " .. vlc.var.get(input, "video-es")
for key, value in pairs( input_object_info ) do
if key == cur_stream_name and value["Frame rate"] then
vlc_fps = value["Frame rate"]
end
end
if not vlc_fps then vlc_fps="--" end

To add an [F] tag to display the video FPS, the following line goes directly below the same line-- "local osd_output = string.gsub(TIME_time_format, "%[E%]", elapsed_time)"

osd_output = string.gsub(osd_output, "%[F%]", vlc_fps)

fferro
New Cone
New Cone
Posts: 3
Joined: 20 Sep 2020 23:40

Re: [Extension] Time

Postby fferro » 20 Sep 2020 23:48

Hi, thank you for this plugin.
I can see an issue with precision.
this example shows it:
30 fps, at 1 second -> 30/30 = 1.000 seconds
but the plugin shows 0.998. Do you know why?

Image

Thanks
Fernando

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] Time

Postby mederi » 24 Sep 2020 16:08

VLC 4 has reworked time management. Perhaps it is better there.

franc
Blank Cone
Blank Cone
Posts: 53
Joined: 12 May 2007 10:06

Re: VLC extension: Time

Postby franc » 08 Jan 2021 12:44

Patches published at http://addons.videolan.org/content/show ... ent=149618
Elapsed time with miliseconds:
...
Thank you mederi for the nice plugin.
I just installed it on my Mac OS 10.11.6 with VLC 3.0.11.1 and I want to contribute a little how-to for this Mac OS:

I downloaded the Time-Plugin: Time_v3.2_(intf).zip and unpacked it.
There are two important files in it, time_intf.lua and time_ext.lua.
I put the time_intf.lua to the intf-folder, here:
/Users/f/Library/Application Support/org.videolan.vlc/lua/intf/time_intf.lua
and the time_ext.lua to the extension folder, here:
/Users/f/Library/Application Support/org.videolan.vlc/lua/extensions/time_ext.lua
(where f is my user name).
Then I noticed that the font is too big and pushy, so I searched and found your comment and hack about it in the 3rd page of the commenting area, starting with: "There is a workaround using marquee filter reading a text file..."


The work-around is for windows and I first thought that I would need this text file (timemarquee.txt), download it from somewhere, but it is just to push the time contents in it and read it, while VLC and the plugin are running, so I created an empty text file in:
/Users/f/Library/Application Support/org.videolan.vlc/lua/intf/time_marquee.txt
(named it time_marquee.txt and not timemarquee.txt for better reading).

In VLC preferences I changed:
'Show all' > Video > Subtitles/OSD > Overlays > [x]Marquee display
and also (still with 'Show all'):
Video > Subtitles/OSD > Marquee > (Text: is empty) Textfile: /Users/f/Library/Application Support/org.videolan.vlc/lua/intf/time_marquee.txt
And also there I can change Font and Position of this Marquee.
With Font > Opacity: 140 and Font > Size: 12 the time pattern is very unpushy :)

Then I changed the code in:
/Users/f/Library/Application Support/org.videolan.vlc/lua/intf/time_intf.lua
(it was in line 108) from:

Code: Select all

... vlc.osd.message(TIME_Decode_time_format(), 1111111111, TIME_osd_position) ...
to:

Code: Select all

... local f = vlc.io.open("/Users/f/Library/Application Support/org.videolan.vlc/lua/intf/time_marquee.txt", "w") if f then f:write(TIME_Decode_time_format()) f:close() end ...
And it worked :)
Thanks again.
frank

EDIT: On Windows 10 I put the extension into the User dir, in:

c:\Users\f\AppData\Roaming\vlc\lua\intf\time_intf.lua
c:\Users\f\AppData\Roaming\vlc\lua\intf\time_marquee.txt
c:\Users\f\AppData\Roaming\vlc\lua\extensions\time_ext.lua

(here also my user name is "f")

and changed the line
vlc.osd.message(...
(see above) in time_intf.lua to:

Code: Select all

... local f = vlc.io.open(vlc.config.userdatadir().."\\lua\\intf\\time_marquee.txt", "w") if f then f:write(TIME_Decode_time_format()) f:close() end ...
The Opacity I have set to 144, font white 18, this is unpushy enough :)

John Cornelivlc
New Cone
New Cone
Posts: 1
Joined: 06 Jan 2021 03:06

Re: [Extension] Time

Postby John Cornelivlc » 10 Jan 2021 21:43

Nice Franc :) , that was helpful for me.

I'd love to insert a time code during transcription: something others have asked about a fair amount - just search the forums for "Transcription".

The scenario: On Windows, I'm listening to VLC, and transcribing into Word (or Notepad). Even though the Word document is active I can use VLC's "Global Hotkey" support to pause/run, jump back and forward the audio I'm transcribing. Super!

Now, I'd love to have Time (v3.3?!) periodically spit out the current time into my Word document.

Questions:
  • If lua/the environment allows, could I just edit time_intf.lua (about line 108 in the TIME_Loop function) to spit out the time to std_out? Presumably the time would then just get displayed in the word processor?
  • How to do this periodically when I wanted during transcriptions:
    • Can a global hotkey activate a script? (A comment above says scripts can't access hotkeys.)
    • So could the Time script put something every 10 seconds into the clipboard, so I could just paste it when desired?
    • Or might Time automatically spit out the time code every 120 seconds say
    • Or is it easy to add this functionality to VLC (I suspect not!),
    • Or what else approaches exist?
Thanks for any ideas on this!

franc
Blank Cone
Blank Cone
Posts: 53
Joined: 12 May 2007 10:06

Re: [Extension] Time

Postby franc » 11 Jan 2021 13:44

I wouldn't have much expectations :(
- Hotkey is not possible as I read, since v2.something. I would love to have some too. It is asked several times here in the forum.
- recurring action of the script seems neither possible, I tried a loop but it runs only one time. I guess such things are blocked. I asked it here, but since no answer.
- adding something to VLC itself must be possible but this might be a very big thing, first successful compile it and then finding where and what to change, ouff. VLC code seems a large one. I wouldnt even start to try, too poor chances (for me at least).

Sorry, I cant help here, I am a mini-developer with my very first steps in Lua and very few (<1) skills in C++ (which I guess is the language behind vlc, must be to be fast enough).

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] Time

Postby mederi » 11 Jan 2021 17:24

@franc: Thanks for the instructions for Mac users. The provided patch with Marquee is meant to use settings different from subtitles and/or position much closer to the edge of the window/screen. I will try to use Marquee filter directly rather than through a text file.

@John Cornelivlc: Check some patches (time to clipboard/file) published within commnets for Jump to time (Previous frame) The only hotkey you could use is the space bar for pause/play (check a patch for Subtitler). Yes, you can check time intervals in time_intf.

brendanefro
New Cone
New Cone
Posts: 4
Joined: 15 Mar 2021 13:58

Re: [Extension] Time

Postby brendanefro » 15 Mar 2021 14:08

Hi Mederi!

I absolutely love this extension and use it every day!

I just wanted to ask if you were planning to release an update so it can work with VLC 4?

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] Time

Postby mederi » 16 Mar 2021 18:26

I will take look at it later this week.

fferro
New Cone
New Cone
Posts: 3
Joined: 20 Sep 2020 23:40

Re: [Extension] Time

Postby fferro » 06 Jun 2021 22:26

Hi,
Could someone explain to me the mathematics behind this plugin, please?
I'm not interested in programming, just knowing if the calculations between frames are accurate.
Does this plugin take into account VFR or just a constant frame rate?
Is based on the PTS of each frame?
Thanks

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] Time

Postby mederi » 08 Jun 2021 10:01

VLC updates elapsed time value several times per second and the extension reads that value even more times per second (10x) during playback. So it is not 100% accurate. Hopefully, at least a paused frame gets the proper time value.

fferro
New Cone
New Cone
Posts: 3
Joined: 20 Sep 2020 23:40

Re: [Extension] Time

Postby fferro » 09 Jun 2021 18:50

thank you mederi. I deal with forensic analysis so, as the value is not accurate, better to not show because it could lead to misinterpretations.


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 1 guest