@@ -56,6 +56,34 @@ if bo_filter:
5656 obs.obs_source_release(bo_filter)
5757```
5858
59+ ** Lua sample code**
60+
61+ ``` lua
62+ local obs = obslua
63+
64+ -- Get the target Branch Output filter by UUID
65+ local bo_filter = obs .obs_get_source_by_uuid (filter_uuid )
66+ if bo_filter ~= nil then
67+ local ph = obs .obs_source_get_proc_handler (bo_filter )
68+ local cd = obs .calldata_create ()
69+ obs .calldata_set_string (cd , " format" , " MyShow %CCYY-%MM-%DD %hh-%mm-%ss" )
70+ obs .proc_handler_call (ph , " override_recording_filename_format" , cd )
71+ obs .calldata_free (cd )
72+ obs .obs_source_release (bo_filter )
73+ end
74+
75+ -- Clear the override (pass an empty string)
76+ local bo_filter = obs .obs_get_source_by_uuid (filter_uuid )
77+ if bo_filter ~= nil then
78+ local ph = obs .obs_source_get_proc_handler (bo_filter )
79+ local cd = obs .calldata_create ()
80+ obs .calldata_set_string (cd , " format" , " " )
81+ obs .proc_handler_call (ph , " override_recording_filename_format" , cd )
82+ obs .calldata_free (cd )
83+ obs .obs_source_release (bo_filter )
84+ end
85+ ```
86+
5987### Overriding the Replay Buffer Save Filename Format
6088
6189A procedure registered on the Branch Output filter source that overrides the output filename format used when the replay buffer is saved.
@@ -96,6 +124,34 @@ if bo_filter:
96124 obs.obs_source_release(bo_filter)
97125```
98126
127+ ** Lua sample code**
128+
129+ ``` lua
130+ local obs = obslua
131+
132+ -- Get the target Branch Output filter by UUID
133+ local bo_filter = obs .obs_get_source_by_uuid (filter_uuid )
134+ if bo_filter ~= nil then
135+ local ph = obs .obs_source_get_proc_handler (bo_filter )
136+ local cd = obs .calldata_create ()
137+ obs .calldata_set_string (cd , " format" , " Replay %CCYY-%MM-%DD %hh-%mm-%ss" )
138+ obs .proc_handler_call (ph , " override_replay_buffer_filename_format" , cd )
139+ obs .calldata_free (cd )
140+ obs .obs_source_release (bo_filter )
141+ end
142+
143+ -- Clear the override (pass an empty string)
144+ local bo_filter = obs .obs_get_source_by_uuid (filter_uuid )
145+ if bo_filter ~= nil then
146+ local ph = obs .obs_source_get_proc_handler (bo_filter )
147+ local cd = obs .calldata_create ()
148+ obs .calldata_set_string (cd , " format" , " " )
149+ obs .proc_handler_call (ph , " override_replay_buffer_filename_format" , cd )
150+ obs .calldata_free (cd )
151+ obs .obs_source_release (bo_filter )
152+ end
153+ ```
154+
99155### Retrieving the Branch Output Filter List
100156
101157A global procedure that returns the list of Branch Output filters currently loaded in OBS. Since the override procedures above require the target filter's UUID, this procedure is typically used to present the filter list to the user for selection.
@@ -161,6 +217,44 @@ def get_branch_output_filters():
161217 return filters
162218```
163219
220+ ** Lua sample code**
221+
222+ Since Lua does not have a built-in JSON parser, we use OBS's ` obs_data_create_from_json() ` to parse the returned JSON string.
223+
224+ ``` lua
225+ local obs = obslua
226+
227+ function get_branch_output_filters ()
228+ local filters = {}
229+ local ph = obs .obs_get_proc_handler ()
230+ local cd = obs .calldata_create ()
231+
232+ if obs .proc_handler_call (ph , " osi_branch_output_get_filter_list" , cd ) then
233+ local json_str = obs .calldata_string (cd , " json" )
234+ if json_str and json_str ~= " " then
235+ local data = obs .obs_data_create_from_json (json_str )
236+ local array = obs .obs_data_get_array (data , " filters" )
237+ local count = obs .obs_data_array_count (array )
238+ for i = 0 , count - 1 do
239+ local item = obs .obs_data_array_item (array , i )
240+ table.insert (filters , {
241+ source_name = obs .obs_data_get_string (item , " source_name" ),
242+ source_uuid = obs .obs_data_get_string (item , " source_uuid" ),
243+ filter_name = obs .obs_data_get_string (item , " filter_name" ),
244+ filter_uuid = obs .obs_data_get_string (item , " filter_uuid" ),
245+ })
246+ obs .obs_data_release (item )
247+ end
248+ obs .obs_data_array_release (array )
249+ obs .obs_data_release (data )
250+ end
251+ end
252+
253+ obs .calldata_free (cd )
254+ return filters
255+ end
256+ ```
257+
164258### Using the Sample Scripts
165259
166260The sample scripts are written in Python. Before using them, make sure that Python Settings are properly configured in OBS under Tools → Scripts.
0 commit comments