├── .gitignore ├── LICENSE ├── README.md ├── streamlink-media └── streamlink-media.py ├── template-switcher ├── example.gif └── template-switcher.py ├── text-clock └── text-clock.lua └── text-reload-interval └── text-reload-interval.lua /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # obs-scripts 2 | Python Scripts for the OBS Scripting Tool 3 | 4 | # Template Switcher 5 | ![Example Use](template-switcher/example.gif) 6 | -------------------------------------------------------------------------------- /streamlink-media/streamlink-media.py: -------------------------------------------------------------------------------- 1 | import streamlink 2 | import obspython as obs 3 | import threading 4 | 5 | globSettings = None 6 | 7 | def script_update(settings): 8 | global globSettings 9 | globSettings = settings 10 | 11 | def script_load(settings): 12 | global globSettings 13 | globSettings = settings 14 | 15 | def script_properties(): 16 | props = obs.obs_properties_create() 17 | obs.obs_properties_add_text(props, "url", "Stream URL", obs.OBS_TEXT_DEFAULT) 18 | 19 | p = obs.obs_properties_add_list(props, "source", "Media Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) 20 | sources = obs.obs_enum_sources() 21 | if sources is not None: 22 | for source in sources: 23 | source_id = obs.obs_source_get_id(source) 24 | if source_id == "ffmpeg_source" or source_id == "vlc_source": 25 | name = obs.obs_source_get_name(source) 26 | obs.obs_property_list_add_string(p, name, name) 27 | 28 | obs.source_list_release(sources) 29 | 30 | r = obs.obs_properties_add_list(props, "res", "Preferred Resolution", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) 31 | obs.obs_property_list_add_string(r, "best", "best") 32 | obs.obs_property_list_add_string(r, "1080p", "1080p") 33 | obs.obs_property_list_add_string(r, "720p", "720p") 34 | obs.obs_property_list_add_string(r, "480p", "480p") 35 | obs.obs_property_list_add_string(r, "360p", "360p") 36 | obs.obs_property_list_add_string(r, "160p", "160p") 37 | obs.obs_property_list_add_string(r, "worst", "worst") 38 | 39 | obs.obs_properties_add_button(props, "set", "Open Stream in Media Source", open_source) 40 | 41 | return props 42 | 43 | def open_source(*args): 44 | print(args) 45 | t = threading.Thread(target=change_input) 46 | t.start() 47 | 48 | def change_input(): 49 | global globSettings 50 | url = obs.obs_data_get_string(globSettings, "url") 51 | source = obs.obs_data_get_string(globSettings, "source") 52 | qual = obs.obs_data_get_string(globSettings, "res") 53 | if url != None and source != None: 54 | sourceObj = obs.obs_get_source_by_name(source) 55 | try: 56 | streamUrl = "" 57 | stream = streamlink.streams(url) 58 | 59 | if qual in stream: 60 | streamUrl = stream[qual].url 61 | elif qual + "60" in stream: 62 | streamUrl = stream[qual + "60"].url 63 | elif qual + "_alt" in stream: 64 | streamUrl = stream[qual + "_alt"].url 65 | elif qual + "60_alt" in stream: 66 | streamUrl = stream[qual + "60_alt"].url 67 | elif "best" in stream: 68 | streamUrl = stream["best"].url 69 | 70 | if streamUrl != "" and sourceObj != None: 71 | source_id = obs.obs_source_get_id(sourceObj) 72 | settings = obs.obs_data_create() 73 | if source_id == "ffmpeg_source": 74 | obs.obs_data_set_string(settings, "input", streamUrl) 75 | obs.obs_data_set_bool(settings, "is_local_file", False) 76 | obs.obs_source_update(sourceObj, settings) 77 | else: 78 | array = obs.obs_data_array_create() 79 | data = obs.obs_data_create() 80 | obs.obs_data_set_string(data, "name", streamUrl) 81 | obs.obs_data_set_string(data, "value", streamUrl) 82 | obs.obs_data_array_push_back(array, data) 83 | obs.obs_data_release(data) 84 | obs.obs_data_set_array(settings, "playlist", array) 85 | obs.obs_source_update(sourceObj, settings) 86 | obs.obs_data_array_release(array) 87 | 88 | obs.obs_data_release(settings) 89 | except streamlink.StreamlinkError: 90 | pass 91 | obs.obs_source_release(sourceObj) -------------------------------------------------------------------------------- /template-switcher/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VodBox/obs-scripts/95a633cdab285b00ab0b59f20455d54bed7c8390/template-switcher/example.gif -------------------------------------------------------------------------------- /template-switcher/template-switcher.py: -------------------------------------------------------------------------------- 1 | import obspython as obs 2 | import math 3 | import json 4 | import os 5 | import sys 6 | import io 7 | import time 8 | import subprocess 9 | import pexpect 10 | import tkinter as tk 11 | import threading 12 | from tkinter import * 13 | from tkinter import filedialog 14 | 15 | class App(threading.Thread): 16 | 17 | def __init__(self): 18 | threading.Thread.__init__(self) 19 | self.start() 20 | 21 | def callback(self): 22 | self.root.withdraw() 23 | 24 | def show(self): 25 | self.root.update() 26 | self.root.deiconify() 27 | 28 | def run(self): 29 | self.root = tk.Tk() 30 | self.root.title("Template Switcher") 31 | self.visible = False 32 | self.visToggled = False 33 | self.root.withdraw() 34 | self.quitted = False 35 | self.root.protocol("WM_DELETE_WINDOW", self.callback) 36 | 37 | self.quitting = False 38 | 39 | self.scene = StringVar() 40 | self.scene.set("Scene") 41 | self.scene.trace("w", self.sceneUpdate) 42 | 43 | self.scenes = ("Scene") 44 | 45 | #self.root.minsize(width=400, height=300) 46 | self.root.resizable(width=False, height=False) 47 | 48 | row = 0 49 | 50 | durLabel = Label(self.root, text="Transition Time (ms)") 51 | durLabel.grid(row=row, column=0) 52 | 53 | self.duration = StringVar() 54 | self.duration.set(str(200)) 55 | self.durEntry = Entry(self.root, textvariable=self.duration) 56 | self.durEntry.grid(row=row,column=1, columnspan=2) 57 | self.duration.trace("w", self.durUpdate) 58 | 59 | row += 1 60 | 61 | self.selection = tk.OptionMenu(self.root, self.scene, self.scenes) 62 | self.selection.grid(row=row, columnspan=3, sticky=N+E+S+W) 63 | 64 | row += 1 65 | 66 | self.list = Listbox(self.root, selectmode=SINGLE) 67 | 68 | self.list.grid(row=row, column=0, rowspan=2, 69 | columnspan=2, sticky=N+E+S+W) 70 | 71 | self.list.insert('end', 'test') 72 | 73 | add = Button(self.root, text="Add", command=self.add) 74 | add.grid(row=row, column=2, sticky=N+E+S+W) 75 | 76 | row += 1 77 | 78 | remove = Button(self.root, text="Remove", command=self.remove) 79 | remove.grid(row=row, column=2, sticky=N+E+S+W) 80 | 81 | row += 1 82 | 83 | save = Button(self.root, text="Save Current Layout as Template", command=self.save) 84 | save.grid(row=row, column=0, columnspan=3, sticky=N+E+S+W) 85 | 86 | row += 1 87 | 88 | switch = Button(self.root, text="Switch to Selected", command=self.switch) 89 | switch.grid(row=row, column=0, columnspan=3, sticky=N+E+S+W) 90 | 91 | self.root.after(16, self.loop) 92 | self.root.mainloop() 93 | 94 | def loop(self): 95 | if self.quitting == False: 96 | if self.visToggled: 97 | self.visToggled = False 98 | if self.visible: 99 | self.root.deiconify() 100 | else: 101 | self.root.withdraw() 102 | self.root.after(16, self.loop) 103 | else: 104 | self.root.destroy() 105 | self.quitted = True 106 | 107 | def quit(self): 108 | self.quitting = True 109 | 110 | def add(self): 111 | global globSettings 112 | loc = filedialog.askopenfilename(filetypes=[("JSON", "*.json")], title="Open Template File") 113 | templates = obs.obs_data_get_array(globSettings, "templates" + self.scene.get()) 114 | if templates == None: 115 | template = obs.obs_data_array_create() 116 | obs.obs_data_set_array(globSettings, "templates" + self.scene.get(), template) 117 | new = obs.obs_data_create() 118 | length = obs.obs_data_array_count(templates) + 1 119 | obs.obs_data_set_string(new, "id", str(length)) 120 | obs.obs_data_set_string(new, "name", os.path.basename(loc)) 121 | obs.obs_data_set_string(new, "loc", loc) 122 | obs.obs_data_array_push_back(templates, new) 123 | obs.obs_data_release(new) 124 | obs.obs_data_array_release(templates) 125 | self.list.insert('end', str(length) + ". " + os.path.basename(loc)) 126 | 127 | def remove(self): 128 | global globSettings 129 | selection = self.list.curselection() 130 | if selection != "": 131 | templates = obs.obs_data_get_array(globSettings, "templates" + self.scene.get()) 132 | obs.obs_data_array_erase(templates, selection[0]) 133 | length = obs.obs_data_array_count(templates) 134 | for i in range(selection[0], length): 135 | item = obs.obs_data_array_item(templates, i) 136 | obs.obs_data_set_string(item, "id", str(i+1)) 137 | obs.obs_data_release(item) 138 | obs.obs_data_array_release(templates) 139 | self.update() 140 | 141 | 142 | def save(self): 143 | currentScene = obs.obs_frontend_get_current_scene() 144 | sceneName = obs.obs_source_get_name(currentScene) 145 | sceneObject = obs.obs_scene_from_source(currentScene) 146 | items = obs.obs_scene_enum_items(sceneObject) 147 | transformations = getTransformationList(items) 148 | loc = filedialog.asksaveasfilename(filetypes=[("JSON", "*.json")], defaultextension=".json", title="Save Template File", initialfile=sceneName + ".json") 149 | f = open(loc,'w') 150 | f.write(json.dumps(transformations)) 151 | f.close() 152 | obs.obs_scene_release(sceneObject) 153 | obs.obs_source_release(currentScene) 154 | 155 | def switch(self): 156 | global globSettings 157 | selection = self.list.curselection() 158 | if selection != "": 159 | templates = obs.obs_data_get_array(globSettings, "templates" + self.scene.get()) 160 | item = obs.obs_data_array_item(templates, selection[0]) 161 | loc = obs.obs_data_get_string(item, "loc") 162 | obs.obs_data_release(item) 163 | obs.obs_data_array_release(templates) 164 | start_animation(loc) 165 | 166 | def update(self): 167 | global globSettings 168 | 169 | self.selection['menu'].delete(0, 'end') 170 | for choice in self.scenes: 171 | self.selection['menu'].add_command(label=choice, command=tk._setit(self.scene, choice)) 172 | stored = obs.obs_data_get_string(globSettings, "scene") 173 | if stored in self.scenes: 174 | self.scene.set(stored) 175 | else: 176 | self.scene.set(self.scenes[0]) 177 | 178 | self.list.delete(0, self.list.index('end')) 179 | 180 | self.duration.set(obs.obs_data_get_int(globSettings, "duration")) 181 | 182 | templates = obs.obs_data_get_array(globSettings, "templates" + self.scene.get()) 183 | if templates == None: 184 | template = obs.obs_data_array_create() 185 | obs.obs_data_set_array(globSettings, "templates" + self.scene.get(), template) 186 | length = obs.obs_data_array_count(templates) 187 | for i in range(length): 188 | item = obs.obs_data_array_item(templates, i) 189 | self.list.insert('end', obs.obs_data_get_string(item, "id") + ". " + obs.obs_data_get_string(item, "name")) 190 | obs.obs_data_release(item) 191 | 192 | obs.obs_data_array_release(templates) 193 | 194 | 195 | def sceneUpdate(self, *args): 196 | global globSettings 197 | obs.obs_data_set_string(globSettings, "scene", self.scene.get()) 198 | self.update() 199 | 200 | def durUpdate(self, *args): 201 | global globSettings 202 | if self.duration.get().isdigit(): 203 | obs.obs_data_set_int(globSettings, "duration", int(self.duration.get())) 204 | else: 205 | self.duration.set(str(obs.obs_data_get_int(globSettings, "duration"))) 206 | 207 | 208 | #app = App() 209 | 210 | globSettings = None 211 | 212 | animationRunning = False 213 | animationInfo = { 214 | 'initial': [], 215 | 'destination': [], 216 | 'animTime': math.inf, 217 | 'stopTime': 10000, 218 | 'animScene': None 219 | } 220 | 221 | def easeInOutQuad(t, b, c, d): 222 | t /= d/2 223 | if t < 1: 224 | return c/2*t*t + b 225 | t-=1 226 | return -c/2 * (t*(t-2) - 1) + b 227 | 228 | def script_tick(tick): 229 | global globSettings 230 | global animationInfo 231 | global animationRunning 232 | global app 233 | global currentScene 234 | 235 | if animationRunning: 236 | animationInfo["animTime"] += tick 237 | animationInfo["animTime"] = min(animationInfo["animTime"], animationInfo["stopTime"]) 238 | scaleFactor = easeInOutQuad(animationInfo["animTime"] / animationInfo["stopTime"], 0, 1, 1) 239 | 240 | animScene = animationInfo["animScene"] 241 | initial = animationInfo["initial"] 242 | destination = animationInfo["destination"] 243 | 244 | result = [] 245 | sceneObject = obs.obs_scene_from_source(animScene) 246 | if obs.obs_source_get_name(animScene) in obs.obs_frontend_get_scene_names(): 247 | items = obs.obs_scene_enum_items(sceneObject) 248 | for i in range(len(initial)): 249 | pos = obs.vec2() 250 | pos.x = scaleFactor*(destination[i]["pos"][0] - initial[i]["pos"][0]) + initial[i]["pos"][0] 251 | pos.y = scaleFactor*(destination[i]["pos"][1] - initial[i]["pos"][1]) + initial[i]["pos"][1] 252 | rot = scaleFactor*(destination[i]["rot"] - initial[i]["rot"]) + initial[i]["rot"] 253 | scale = obs.vec2() 254 | scale.x = scaleFactor*(destination[i]["scale"][0] - initial[i]["scale"][0]) + initial[i]["scale"][0] 255 | scale.y = scaleFactor*(destination[i]["scale"][1] - initial[i]["scale"][1]) + initial[i]["scale"][1] 256 | alignment = destination[i]["alignment"] 257 | bounds = obs.vec2() 258 | bounds.x = scaleFactor*(destination[i]["bounds"][0] - initial[i]["bounds"][0]) + initial[i]["bounds"][0] 259 | bounds.y = scaleFactor*(destination[i]["bounds"][1] - initial[i]["bounds"][1]) + initial[i]["bounds"][1] 260 | boundsType = destination[i]["boundsType"] 261 | boundsAlignment = destination[i]["boundsAlignment"] 262 | crop = obs.obs_sceneitem_crop() 263 | crop.left = math.floor(scaleFactor*(destination[i]["crop"][0] - initial[i]["crop"][0]) + initial[i]["crop"][0]) 264 | crop.right = math.floor(scaleFactor*(destination[i]["crop"][1] - initial[i]["crop"][1]) + initial[i]["crop"][1]) 265 | crop.top = math.floor(scaleFactor*(destination[i]["crop"][2] - initial[i]["crop"][2]) + initial[i]["crop"][2]) 266 | crop.bottom = math.floor(scaleFactor*(destination[i]["crop"][3] - initial[i]["crop"][3]) + initial[i]["crop"][3]) 267 | obs.obs_sceneitem_set_pos(items[i], pos) 268 | obs.obs_sceneitem_set_rot(items[i], rot) 269 | obs.obs_sceneitem_set_scale(items[i], scale) 270 | obs.obs_sceneitem_set_alignment(items[i], alignment) 271 | obs.obs_sceneitem_set_bounds(items[i], bounds) 272 | obs.obs_sceneitem_set_bounds_type(items[i], boundsType) 273 | obs.obs_sceneitem_set_bounds_alignment(items[i], boundsAlignment) 274 | obs.obs_sceneitem_set_crop(items[i], crop) 275 | obs.sceneitem_list_release(items) 276 | 277 | #obs.obs_scene_release(sceneObject) 278 | 279 | if animationInfo["animTime"] == animationInfo["stopTime"]: 280 | obs.obs_source_release(animScene) 281 | animationInfo["animScene"] = None 282 | animationRunning = False 283 | 284 | def start_animation(info): 285 | global animationInfo 286 | global globSettings 287 | global animationRunning 288 | 289 | animationInfo["animTime"] = 0 290 | animationInfo["stopTime"] = obs.obs_data_get_int(globSettings, "duration")/1000 291 | 292 | f = open(info,'r') 293 | animationInfo["destination"] = json.loads(f.read()) 294 | f.close() 295 | 296 | animationInfo["animScene"] = obs.obs_get_source_by_name(obs.obs_data_get_string(globSettings, "scene")) 297 | 298 | sceneObject = obs.obs_scene_from_source(animationInfo["animScene"]) 299 | items = obs.obs_scene_enum_items(sceneObject) 300 | animationInfo["initial"] = getTransformationList(items) 301 | 302 | animationRunning = True 303 | 304 | #obs.obs_scene_release(sceneObject) 305 | 306 | # ------------------------------------------------------------ 307 | 308 | # A function named script_properties defines the properties that the user can 309 | # change for the entire script module itself 310 | def script_properties(): 311 | global globSettings 312 | 313 | props = obs.obs_properties_create() 314 | obs.obs_properties_add_button(props, "open", "Open GUI", open_gui) 315 | return props 316 | 317 | def open_gui(*args): 318 | global app 319 | global globSettings 320 | app.show() 321 | currentScene = obs.obs_frontend_get_current_scene() 322 | sceneName = obs.obs_source_get_name(currentScene) 323 | obs.obs_data_set_string(globSettings, "scene", sceneName) 324 | obs.obs_source_release(currentScene) 325 | scenes = obs.obs_frontend_get_scene_names() 326 | result = [] 327 | if scenes is not None: 328 | for scene in scenes: 329 | result.append(scene) 330 | app.scenes = tuple(result) 331 | app.scene.set(sceneName) 332 | app.update() 333 | 334 | # a function name script_description returns the description shown to the user 335 | def script_description(): 336 | return "Allows for smooth switching between user made templates, within a scene\n\nMade by Dillon (VodBox)" 337 | 338 | # A function named script_update will be called when settings are changed 339 | def script_update(settings): 340 | global globSettings 341 | 342 | globSettings = settings 343 | 344 | # A function named script_defaults will be called to set the default settings 345 | def script_defaults(settings): 346 | obs.obs_data_set_default_int(settings, "duration", 200) 347 | currentScene = obs.obs_frontend_get_current_scene() 348 | sceneName = obs.obs_source_get_name(currentScene) 349 | obs.obs_data_set_string(settings, "scene", sceneName) 350 | obs.obs_source_release(currentScene) 351 | 352 | # A function named script_load will be called on startup 353 | def script_load(settings): 354 | global globSettings 355 | global app 356 | global animationInfo 357 | animationInfo = { 358 | 'initial': [], 359 | 'destination': [], 360 | 'animTime': math.inf, 361 | 'stopTime': 10000, 362 | 'animScene': None 363 | } 364 | app = App() 365 | globSettings = settings 366 | 367 | def script_unload(): 368 | global app 369 | global globSettings 370 | global animationInfo 371 | 372 | if animationInfo["animScene"] != None: 373 | obs.obs_source_release(animationInfo["animScene"]) 374 | 375 | app.quit() 376 | while app.quitted == False: 377 | pass 378 | 379 | obs.obs_data_release(globSettings) 380 | 381 | return 382 | 383 | def save(*args): 384 | currentScene = obs.obs_frontend_get_current_scene() 385 | sceneName = obs.obs_source_get_name(currentScene) 386 | sceneObject = obs.obs_scene_from_source(currentScene) 387 | items = obs.obs_scene_enum_items(sceneObject) 388 | transformations = getTransformationList(items) 389 | loc = filedialog.asksaveasfilename(filetypes=[("JSON", "*.json")], title="Save Template File", initialfile=sceneName + ".json") 390 | f = open(loc,'w') 391 | f.write(json.dumps(transformations)) 392 | f.close() 393 | #obs.obs_scene_release(sceneObject) 394 | obs.obs_source_release(currentScene) 395 | return True 396 | 397 | def getTransformationList(sceneitems): 398 | transformations = [] 399 | for sceneitem in sceneitems: 400 | pos = obs.vec2() 401 | obs.obs_sceneitem_get_pos(sceneitem, pos) 402 | rot = obs.obs_sceneitem_get_rot(sceneitem) 403 | scale = obs.vec2() 404 | obs.obs_sceneitem_get_scale(sceneitem, scale) 405 | alignment = obs.obs_sceneitem_get_alignment(sceneitem) 406 | bounds = obs.vec2() 407 | obs.obs_sceneitem_get_bounds(sceneitem, bounds) 408 | boundsType = obs.obs_sceneitem_get_bounds_type(sceneitem) 409 | boundsAlignment = obs.obs_sceneitem_get_bounds_alignment(sceneitem) 410 | crop = obs.obs_sceneitem_crop() 411 | obs.obs_sceneitem_get_crop(sceneitem, crop) 412 | transformations.append({"pos": [pos.x, pos.y], "rot": rot, "scale": [scale.x, scale.y], "alignment": alignment, "bounds": [bounds.x, bounds.y], "boundsType": boundsType, "boundsAlignment": boundsAlignment, "crop": [crop.left, crop.right, crop.top, crop.bottom]}) 413 | obs.obs_sceneitem_release(sceneitem) 414 | return transformations 415 | -------------------------------------------------------------------------------- /text-clock/text-clock.lua: -------------------------------------------------------------------------------- 1 | obs = obslua 2 | source_name = "" 3 | twentyfour = false 4 | seconds = true 5 | prefix = "" 6 | suffix = "" 7 | lead = true 8 | last_text = "" 9 | activated = false 10 | 11 | function timer_callback() 12 | local theDate = os.date((twentyfour and "%H:" or "%I:") .. "%M" .. (seconds and ":%S" or "") .. (twentyfour and "" or "%p"), os.time()) 13 | if not lead then 14 | theDate = theDate:match("^0?(.+)") 15 | end 16 | local text = (prefix ~= "" and prefix .. " " or "") .. theDate .. (suffix ~= "" and " " .. suffix or "") 17 | if text ~= nil and text ~= last_text then 18 | local source = obs.obs_get_source_by_name(source_name) 19 | if source ~= nil then 20 | local settings = obs.obs_data_create() 21 | obs.obs_data_set_string(settings, "text", text) 22 | obs.obs_source_update(source, settings) 23 | obs.obs_data_release(settings) 24 | obs.obs_source_release(source) 25 | end 26 | end 27 | last_text = text 28 | end 29 | 30 | function activate(activating) 31 | if activating then 32 | timer_callback() 33 | obs.timer_add(timer_callback, 32) 34 | else 35 | obs.timer_remove(timer_callback) 36 | end 37 | end 38 | 39 | -- Called when a source is activated/deactivated 40 | function activate_signal(cd, activating) 41 | local source = obs.calldata_source(cd, "source") 42 | if source ~= nil then 43 | local name = obs.obs_source_get_name(source) 44 | if (name == source_name) then 45 | activate(activating) 46 | end 47 | end 48 | end 49 | 50 | function source_activated(cd) 51 | activate_signal(cd, true) 52 | end 53 | 54 | function source_deactivated(cd) 55 | activate_signal(cd, false) 56 | end 57 | 58 | function reset(pressed) 59 | if not pressed then 60 | return 61 | end 62 | 63 | activate(false) 64 | local source = obs.obs_get_source_by_name(source_name) 65 | if source ~= nil then 66 | local active = obs.obs_source_active(source) 67 | obs.obs_source_release(source) 68 | activate(active) 69 | end 70 | end 71 | 72 | function reset_button_clicked(props, p) 73 | reset(true) 74 | return false 75 | end 76 | 77 | ---------------------------------------------------------- 78 | 79 | -- A function named script_properties defines the properties that the user 80 | -- can change for the entire script module itself 81 | function script_properties() 82 | local props = obs.obs_properties_create() 83 | obs.obs_properties_add_bool(props, "twentyfour", "24 Hour Time") 84 | obs.obs_properties_add_bool(props, "seconds", "Display Seconds") 85 | obs.obs_properties_add_bool(props, "lead", "Leading Zeros") 86 | obs.obs_properties_add_text(props, "prefix", "Prefix", obs.OBS_TEXT_DEFAULT) 87 | obs.obs_properties_add_text(props, "suffix", "Suffix", obs.OBS_TEXT_DEFAULT) 88 | local p = obs.obs_properties_add_list(props, "source", "Text Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) 89 | local sources = obs.obs_enum_sources() 90 | if sources ~= nil then 91 | for _, source in ipairs(sources) do 92 | source_id = obs.obs_source_get_id(source) 93 | if source_id == "text_gdiplus" or source_id == "text_ft2_source" then 94 | local name = obs.obs_source_get_name(source) 95 | obs.obs_property_list_add_string(p, name, name) 96 | end 97 | end 98 | end 99 | obs.source_list_release(sources) 100 | return props 101 | end 102 | 103 | -- A function named script_description returns the description shown to 104 | -- the user 105 | function script_description() 106 | return "Sets a text source to show current time.\n\nMade by VodBox\n\nBased on Countdown Script by Jim" 107 | end 108 | 109 | -- A function named script_update will be called when settings are changed 110 | function script_update(settings) 111 | activate(false) 112 | 113 | twentyfour = obs.obs_data_get_bool(settings, "twentyfour") 114 | seconds = obs.obs_data_get_bool(settings, "seconds") 115 | lead = obs.obs_data_get_bool(settings, "lead") 116 | prefix = obs.obs_data_get_string(settings, "prefix") 117 | suffix = obs.obs_data_get_string(settings, "suffix") 118 | source_name = obs.obs_data_get_string(settings, "source") 119 | 120 | reset(true) 121 | end 122 | 123 | -- A function named script_defaults will be called to set the default settings 124 | function script_defaults(settings) 125 | obs.obs_data_set_default_bool(settings, "twentyfour", false) 126 | obs.obs_data_set_default_bool(settings, "seconds", true) 127 | obs.obs_data_set_default_bool(settings, "lead", true) 128 | end 129 | 130 | -- a function named script_load will be called on startup 131 | function script_load(settings) 132 | local sh = obs.obs_get_signal_handler() 133 | obs.signal_handler_connect(sh, "source_activate", source_activated) 134 | obs.signal_handler_connect(sh, "source_deactivate", source_deactivated) 135 | end 136 | -------------------------------------------------------------------------------- /text-reload-interval/text-reload-interval.lua: -------------------------------------------------------------------------------- 1 | obs = obslua 2 | source_name = "" 3 | interval = 1000 4 | file = "" 5 | last_text = "" 6 | activated = false 7 | 8 | function timer_callback() 9 | local f = assert(io.open(file, "r")) 10 | local text = f:read("*all") 11 | f:close() 12 | if text ~= nil and text ~= last_text then 13 | local source = obs.obs_get_source_by_name(source_name) 14 | if source ~= nil then 15 | local settings = obs.obs_data_create() 16 | obs.obs_data_set_string(settings, "text", text) 17 | obs.obs_source_update(source, settings) 18 | obs.obs_data_release(settings) 19 | obs.obs_source_release(source) 20 | end 21 | end 22 | last_text = text 23 | end 24 | 25 | function activate(activating) 26 | if activating then 27 | timer_callback() 28 | obs.timer_add(timer_callback, interval) 29 | else 30 | obs.timer_remove(timer_callback) 31 | end 32 | end 33 | 34 | -- Called when a source is activated/deactivated 35 | function activate_signal(cd, activating) 36 | local source = obs.calldata_source(cd, "source") 37 | if source ~= nil then 38 | local name = obs.obs_source_get_name(source) 39 | if (name == source_name) then 40 | activate(activating) 41 | end 42 | end 43 | end 44 | 45 | function source_activated(cd) 46 | activate_signal(cd, true) 47 | end 48 | 49 | function source_deactivated(cd) 50 | activate_signal(cd, false) 51 | end 52 | 53 | function reset(pressed) 54 | if not pressed then 55 | return 56 | end 57 | 58 | activate(false) 59 | local source = obs.obs_get_source_by_name(source_name) 60 | if source ~= nil then 61 | local active = obs.obs_source_active(source) 62 | obs.obs_source_release(source) 63 | activate(active) 64 | end 65 | end 66 | 67 | function reset_button_clicked(props, p) 68 | reset(true) 69 | return false 70 | end 71 | 72 | ---------------------------------------------------------- 73 | 74 | -- A function named script_properties defines the properties that the user 75 | -- can change for the entire script module itself 76 | function script_properties() 77 | local props = obs.obs_properties_create() 78 | obs.obs_properties_add_int(props, "interval", "Interval (ms)", 1, 100000, 50) 79 | obs.obs_properties_add_path(props, "file", "Text File", obs.OBS_PATH_FILE, "Text File (*.txt)", nil) 80 | local p = obs.obs_properties_add_list(props, "source", "Text Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) 81 | local sources = obs.obs_enum_sources() 82 | if sources ~= nil then 83 | for _, source in ipairs(sources) do 84 | source_id = obs.obs_source_get_id(source) 85 | if source_id == "text_gdiplus" or source_id == "text_ft2_source" then 86 | local name = obs.obs_source_get_name(source) 87 | obs.obs_property_list_add_string(p, name, name) 88 | end 89 | end 90 | end 91 | obs.source_list_release(sources) 92 | return props 93 | end 94 | 95 | -- A function named script_description returns the description shown to 96 | -- the user 97 | function script_description() 98 | return "Sets a text source to show contents of a file on a timer.\n\nMade by VodBox\n\nBased on Countdown Script by Jim" 99 | end 100 | 101 | -- A function named script_update will be called when settings are changed 102 | function script_update(settings) 103 | activate(false) 104 | 105 | interval = obs.obs_data_get_int(settings, "interval") 106 | source_name = obs.obs_data_get_string(settings, "source") 107 | file = obs.obs_data_get_string(settings, "file") 108 | 109 | reset(true) 110 | end 111 | 112 | -- A function named script_defaults will be called to set the default settings 113 | function script_defaults(settings) 114 | obs.obs_data_set_default_int(settings, "interval", 1000) 115 | end 116 | 117 | -- a function named script_load will be called on startup 118 | function script_load(settings) 119 | local sh = obs.obs_get_signal_handler() 120 | obs.signal_handler_connect(sh, "source_activate", source_activated) 121 | obs.signal_handler_connect(sh, "source_deactivate", source_deactivated) 122 | end 123 | --------------------------------------------------------------------------------