[Solved]Bug when cropping a video capture source

khaver

Member
I think I found a bug. Will need others to try and verify.

If you have a video capture source set to deactivate when not shown, and you crop the preview image using either the alt-drag frame method or you use the edit transform settings, then add a Lua installed filter, such as the halftone filter from the OBS scripting tutorial, or any of my Lua filters, then deactivate the source either by switching to another scene or using the visibility "eye" icon for the source, then reactivate it, it does not show up. If you double click the source in the source list to bring up its properties, it immediately appears. Or if you right click on the source in the list and select to edit the transforms, you will see that both the width and height has changed to 0 or one of them has, rendering it invisible in the preview. If you keep the transform dialog open and double click the source to open its properties, the width and height numbers update to the correct numbers and the source reappears in the preview.

Again this only happens when the source is set to deactivate when not shown and a Lua installed filter is added to it. This does not happen with the in-built filters.

There are no errors in the log when this happens.

I think this may be happening because of how Lua scripted filter code reports the width and height of a source to the OBS display. When the source is deactivate it usually takes up to a second for the camera to reactivate, so the filter is trying to read a texture from the GPU that isn't there. There must be some difference in how the built-in filters are implemented compared to Lua installed ones.
 

khaver

Member
It's not an OBS bug. It is a flaw in the Lua scripts.
In ...video_render = function(filter), the first statement needs to be the obs.obs_source_process_filter_begin(... function.

The halftone.lua tutorial places it after:
Code:
  local parent = obs.obs_filter_get_parent(filter.source)
  filter.width = obs.obs_source_get_base_width(parent)
  filter.height = obs.obs_source_get_base_height(parent)

With the obs_source_process_filter_begin function placed at the top of the video_render function, video capture sources now show when reactivated even if you've cropped the source.

This took a bit of trial and error and studying the order of statements in the built-in function source code.

I'll update all my Lua scripts.
 
Top