When writing code for OBS, a very time-consuming task is to browse the huge OBS API to determine which functions or combinations of functions are required to reach OBS data.Ī quick search for "rotation" in the OBS API points out one promising function among many results: obs_sceneitem_set_rot sets the rotation angle of a "scene item" ( obs_sceneitem_get_rot to retrieve the current angle). The basis is in place (we will come back to properties and hotkey later on) and we want to find out how to rotate the source. One parameter is the "Rotation" that will be changed by the script. The same source in another scene would have another transform linked to its "scene item" (more about that in the next section). Please note that the "transform" of a source depends on its actual position in a given scene. To do it: select the source, right-click on it, Transform > Edit transform., for Positional Alignment select Center, then Close (changing the alignment will change the position of the source): It is not absolutely necessary but the shake effect looks better if the source rotates around its center than around one of its corners. For this tutorial, let's call the source "Spaceship" such that it is easily identifiable (adapt the name as convenient).Īs we will rotate the source, it is better to have it centered. A self-contained Data URI of a PNG or BMP file can be used as well to show a picture in the description.Īt this point, set a source in OBS (an image, your webcam, whatever) and give it a name. Please note that the description string is displayed by Qt, meaning that a subset of HTML can be used for formatting. Source Shake Scripting Tutorial on the OBS Wiki for more information.]]Īfter reloading the script, the description should now be displayed: In Lua: - Description displayed in the Scripts dialog window Source Shake Scripting Tutorial on the OBS Wiki for more information.""" Then Hotkeys to select the key combination.Check the Shake a source in the current scene when a hotkey is pressed. # Description displayed in the Scripts dialog window Again by convention, because it is shorter and some code snippets are then similar in Lua and Python, a global variable called obs usually references the module:Īs a next step, create the function called script_description with no arguments, which is expected to return a character string containing the description of the script. In Lua the obslua module is pre-imported, as well as the available standard modules.By convention, it is imported as obs (and we import already some additional Python modules): In a Python script, it is mandatory to import the obspython module because the interpreter is not embedded.If it worked, you can remove the Hello World line from your file.Īt the top of the script, insert some line(s) as following: ![]() Please note that print does the job but is not the best choice for logging, consider using blog instead. For now write only the following line in the file, which works for Python and Lua: print("Hello World!")Īdd the file in the Scripts dialog window, open the script log, you should see something like this: ![]() Use a text editor and create a file named source-shake.py or a (both Python and Lua versions of the code will be given in the next sections). If you cannot wait and want to see how the Source Shake effect behaves, the complete scripts are available in Python and Lua. In other words, for a given source already present in OBS and displayed on the current scene, we want to continuously rotate it back and forth according to a given frequency and angular amplitude, such that the source jiggles, when the user presses a key continuously.ĭepending how you came to this page, it is advisable now to take a look at the OBS scripting documentation and the scripting introduction on the Wiki if not already done. As an educational example, we want to make a script that can "shake a source" when the user hits a hotkey. This page proposes a tutorial for Python and Lua scripting.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |