Skip to content

Commit 8a7018a

Browse files
bozlospessoni
andauthored
Added Date and UTC feature (#1)
* Added Date and UTC feature * Revert Change. Fix for 12hr Time. * Updated version information * Updated Docs. Added Date / UTC / Contributor information Co-authored-by: spessoni <84045933+spessoni@users.noreply.github.com>
1 parent b63b88a commit 8a7018a

3 files changed

Lines changed: 40 additions & 5 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Generate timecode (HH:MM:SS:FF) for a text source based on the computers RTC (Re
1515

1616
![Timecode Demo](docs/tc-animation.gif?raw=true)
1717

18-
The script was written to create accurate timecode which is based on the computer's time of day. It can be used for creating slates, time labels on security footage, live cameras, etc. It is useful for checking latency with other live sources and encoders.
18+
The script was written to create accurate timecode which is based on the computer's time of day. It can be used for creating slates, time labels on security footage, live cameras, etc. It is useful for checking latency with other live sources and encoders. The Date and Time will be shown with your local time offsets unless *show UTC(GMT)* is checked.
1919

2020
## Settings
2121

@@ -24,6 +24,8 @@ The script was written to create accurate timecode which is based on the compute
2424
* **Text Source**: This is the source to which the timecode text will be applied.
2525
* **Mode**: Select the clock mode of either 24 Hour, 12 Hour, or 12 Hour with AM/PM displayed.
2626
* **Show Frames**: Checking this will display the frames component (:FF) of the timecode. This could potentially slow down older computers because every frame must be rendered. You can keep an eye on this with the CPU usage box at the bottom right corner of the OBS application.
27+
* **Show Date**: The date will be displayed when this is checked. (YYYY-MM-DD)
28+
* **Show UTC(GMT)**: When checked, the time and date will be displayed in Coordinated Universal Time (UTC). Coordinated Universal Time or UTC is the primary time standard by which the world regulates clocks and time. It is not adjusted for daylight saving time. It is effectively a successor to Greenwich Mean Time (GMT).
2729
* **Prefix Text**: This text will be applied *in front of the timecode*. You may want to add a space at the end, if needed, to add padding to the text.
2830
* **Suffix Text**: This text will be applied *at the end of the timecode*. You may want to add a space at the end, if needed, to add padding to the text.
2931
* **Update when not in program**: When checked, the time will continue to be updated even when not in program. This can be useful when making isolated recordings for later logging, keeping timecode running on the OBS multiviewer, sending via NDI feeds, ect. By default it is disabled to minimize CPU load, especially with "*show frames*" checked.
@@ -47,3 +49,7 @@ The Lua `os.date` function only reliably returns seconds. To get frame accuracy
4749
* **Timecode does not advance:** Make sure the source is in program and currently active or enable "Update when not in program". Also make sure the correct source is set and hasn't been renamed.
4850
* **Clock is not correct:** Make sure your computer's clock is displaying correctly, including time zone and daylight savings / standard time. You may also want to synchronize your computer's clock with an internet time server.
4951
* **My CPU usage goes up when I select frames:** Unfortunately this is unavoidable. Each frame is required to be processed and rendered. On most machines, this will only add 1-2% max to the CPU processing load.
52+
53+
## Contributors
54+
* **Scott Pessoni** ([spessoni](https://github.com/spessoni)): Initial Release / Project Maintainer
55+
* **Iljun Lee** ([bozlo](https://github.com/bozlo)): Added Date and UTC options

docs/settings.png

480 Bytes
Loading

timecode-text.lua

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ OBS RTC Timecode Generator for Text Sources
33
Generate timecode (HH:MM:SS:FF) for a text source based on the computers RTC (Real-Time Clock)
44
For updates, documentation and more information see the project page at: https://github.com/spessoni/obs-timecode-text
55
----------------------------------
6-
v1.0 (2021/06/08): Initial Release
6+
v1.0 (2021/06/08): Initial Release (spessoni)
7+
v1.01 (2021/12/30): Added Date & UTC (bozlo)
78
]]
89

910
obs = obslua
@@ -19,6 +20,8 @@ frame_text = "" -- Frame text (String)
1920
source_name = "" -- Text source name
2021
time_mode = "24 Hour" -- Clock mode
2122
show_frame = false -- Enable showing frames ":FF"
23+
show_date = false -- Enable showing date (yyyy-mm-dd)
24+
show_utc = false -- Enable showing date and time as UTC
2225
pre_text = "" -- Text before timecode
2326
post_text = "" -- Text after timecode
2427
keep_updated = false -- Update when not in program
@@ -31,10 +34,13 @@ Format12hr = "%I:%M:%S"
3134
Format24hr = "%H:%M:%S"
3235
FormatAmPm = "%p"
3336

37+
FormatDate = "%Y-%m-%d "
38+
FormatUtc = "!"
39+
3440
-- Description
3541
-- Logo Image - Base64 Encoded Image - https://www.base64-image.de/
3642
img_logo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALwAAAA3BAMAAABEED2DAAAAGFBMVEUAAAAAAAD+//5XV1ebm5sqKysZGhrKysuA4j2YAAAAAXRSTlMAQObYZgAABChJREFUWMPtlk1z2jAQhvsTuvjjjiTqsyxoz5YVchbU5Gw+pndD/n/flQx1GSATmmbaTnfaQa8kPzGr1bt86IPeOHrse+J3TeOpQWBIlLUUI8fMCoueZ3dRcWBrS6v44IqVZ7W6ii+F+EQCgaGmhe7xCWYkWTEhi4Ulq+P8PAvDEjM5HobK1XW8c4UvnHO0EXKAd52raVrMyercLpWDCtsPTu0YnxSu00/KFY2kJ3kd7/HWikd2X+iIPy4QKZ7eiuWEYoQ/1jBt9ExPY3zfcibzTr+MT1VbTi7hhRjikfQs4CtKx9iT7eQa+iremEIXxvh0TEnEb4z5PMB/UeVSGnPC0xAPpfDyt45W8tHqH/iFEJMBHhQ+2qt4LN3Al9KTQrmlQER8hnIb4HOPt2+aq3hpqxv4pdBMIcZfzD2Gt3O/uJV7/0VGPJJzHX9/5SSF5rqP+INz+oSPdY/hWd0XUK+pe4GIeAyqE/7arYVS12/tP+SYb4n/Hy8H/dZ4F3zJNolbEp2YVQWl4ZeqXUQbxWK/VUbbl7DfEQZjqDnm58RqEm4X4wb46WPhdGIPbSppOynZDcrDo0yEsw/whk4LOEVLiE0BZaE2AY+dFVThE7xIiqY5D95QuEc5TE5yNL7Cl5NSQ+CJLlX0TcLZykpQH4tnKseWn1At8Gwa1sPHvoVGYgl7yc4UDOMiXhxExCsik04oYfxogK8o0QEvqhMeVglLkxHvaQE8XcZLISflrPGMpwEePabH7xpvoZCNnRo9NCu87FLM2MsG+ObrZfzYLvlox+d4nFWPX4TDrBJpaxxtPOg9d5UBHtsfLuPNZlLWRp/jjfE9foPcG6MTuS3UaG9mZK3UGWx/gC+6fXsZT8kp93Q596N4tDK3fe6XouVSHCZnLekFfJvbVEb8eoCf07rH06jHezsfJId7osqEPsdn5b6N+Bpf3tZTlQhT7he16TSSY8LX3SrTVRYq1v2ed/q0aE74L9IUM4WPc/zPt3bLd7EUhf751uZWyPbs1vrczk54UGR2Xvf5KvzOptzj365B4UG1lDUr/D/9KufYQfEGfmKVYeB3mGxZ4ZNOv8Pj9r/cMf/H+7TGj38Efuppq2t8ssCQUu2g2rjo5pQff9umDt1q6iBfgS81nCvewRVR9Bw4kGeV8PVd80Vmdey14j58JoGXWVeJ563wQe25Geq8Cw3n2K0Q9+DzGkAxFZVQpfBBwVUrG1JV/zKeY2GFrYQtOh/UnoEx8/fi2TEFIuKNQu63n5gSDZHW7KYcx2ZYvQp/cLZCd+si/nONbpVUwMfK6TQqR7UBf3A1Wef0/cmJzXCQg3JMlLP65dxncoiH6pthyy1V/Q68bOzYPizFLfz9yck7oSgVYn9/5Sw9bbQhMkFtPCVBtXHRfKbcGB1EookX/ihLe0P8d01J5Amxe24GAAAAAElFTkSuQmCC"
37-
version = "Version 1.00 - <a href='https://github.com/spessoni/obs-timecode-text'>spessoni</a>"
43+
version = "Version 1.01 - <a href='https://github.com/spessoni/obs-timecode-text'>spessoni</a>"
3844
description = [[
3945
<center><img width='188' height='55' src=']] .. img_logo .. [['/><br>]] .. version .. [[</center>
4046
<h3>Generates Real-Time Clock (RTC) Timecode on a text source</h3>
@@ -62,12 +68,25 @@ function set_text()
6268
if time_mode == "12 Hour + AM/PM" or time_mode == "12 Hour" then
6369
format = Format12hr
6470
end
71+
72+
if ( show_date ) then
73+
format = FormatDate .. format
74+
end
75+
76+
if ( show_utc ) then
77+
format = FormatUtc .. format
78+
end
79+
6580
local time = os.date(format)
6681

6782
-- Get AM/PM if requested
6883
local ampm = ""
6984
if time_mode == "12 Hour + AM/PM" then
70-
ampm = " " .. os.date(FormatAmPm)
85+
format = FormatAmPm
86+
if ( show_utc ) then
87+
format = FormatUtc .. format
88+
end
89+
ampm = " " .. os.date(format)
7190
end
7291

7392
-- Update frame counter if enabled
@@ -147,6 +166,12 @@ function script_properties()
147166
local p_show_frame = obs.obs_properties_add_bool(props, "show_frame", "Show Frames")
148167
obs.obs_property_set_long_description(p_show_frame, "<b>NOTE:</b> This may require more CPU usage")
149168

169+
-- Show Date Checkbox
170+
local p_show_date = obs.obs_properties_add_bool(props, "show_date", "Show Date")
171+
172+
-- Show UTC Checkbox
173+
local p_show_utc = obs.obs_properties_add_bool(props, "show_utc", "Show UTC(GMT)")
174+
150175
-- Prefix Text
151176
obs.obs_properties_add_text(props, "pre_text", "Prefix Text", obs.OBS_TEXT_DEFAULT)
152177

@@ -165,6 +190,8 @@ function script_update(settings)
165190
source_name = obs.obs_data_get_string(settings, "source")
166191
time_mode = obs.obs_data_get_string(settings, "time_mode")
167192
show_frame = obs.obs_data_get_bool(settings, "show_frame")
193+
show_date = obs.obs_data_get_bool(settings, "show_date")
194+
show_utc = obs.obs_data_get_bool(settings, "show_utc")
168195
pre_text = obs.obs_data_get_string(settings, "pre_text")
169196
post_text = obs.obs_data_get_string(settings, "post_text")
170197
keep_updated = obs.obs_data_get_bool(settings, "keep_updated")
@@ -177,7 +204,7 @@ function script_update(settings)
177204
if (source_active or keep_updated) and not show_frame then
178205
if debug then print ("script_update(): Timer Callback ENABLED") end
179206
cb_toggle(true)
180-
else
207+
else
181208
if debug then print ("script_update(): Timer Callback DISABLED") end
182209
cb_toggle(false)
183210
end
@@ -189,6 +216,8 @@ function script_defaults(settings)
189216
obs.obs_data_set_default_string(settings, "source", "")
190217
obs.obs_data_set_default_string(settings, "time_mode", "24 Hour")
191218
obs.obs_data_set_default_bool(settings, "show_frame", false)
219+
obs.obs_data_set_default_bool(settings, "show_date", false)
220+
obs.obs_data_set_default_bool(settings, "show_utc", false)
192221
obs.obs_data_set_default_string(settings, "pre_text", "")
193222
obs.obs_data_set_default_string(settings, "post_text", "")
194223
obs.obs_data_set_default_bool(settings, "keep_updated", false)

0 commit comments

Comments
 (0)