Question / Help Camera feed freezes permanently in OBS Studio at random times

FlyingFathead

New Member
Hi there!

Today, I made a simple script to reload your desired USB webcam source every x minutes (user definable). I've noticed this works great in handling things like webcam freezes, or i.e. in cases where you're doing outdoor streams and the camera doesn't adjust to changes in lighting conditions.

I have added the code to this site's Resources-category (however, as of writing this, it's still waiting to be accepted):

The code is also available from my Github pages as a gist.

Or, you can just use this snippet below and save it as (i.e.) "WebcamReload.lua", change the interval and the 'UVC Webcam' source name to whatever name you have given your video source in OBS's video sources list. Here:

Lua:
-- Install: open up a plaintext editor, copy-paste this code in and save it as (i.e.): ReloadWebcam.lua

-- [start of lua code]

obs = obslua

-- The name of the video source is what the title of it is in your OBS video sources list.
-- For clarity, you can i.e. rename your video source in OBS to 'Cam1', 'Cam2' etc and then just add a variation of this script per each camera that you want to refresh as a source every x minutes.

-- Replace 'UVC Webcam' value below with the name of your video capture source
local source_name = 'UVC Webcam'

-- Replace the value underneath (default: 1) with the number of minutes between source reloads
local reload_interval_minutes = 1

local function reload_source()
local source = obs.obs_get_source_by_name(source_name)
if source ~= nil then
obs.obs_source_inc_showing(source)
obs.obs_source_dec_showing(source)
obs.obs_source_release(source)
end
end

local function timer_callback()
reload_source()
obs.remove_current_callback()
obs.timer_add(timer_callback, reload_interval_minutes * 60 * 1000)
end

function script_load(settings)
obs.timer_add(timer_callback, reload_interval_minutes * 60 * 1000)
end

function script_unload()
-- stop timers when script is unloaded
obs.timer_remove(timer_callback)
end

-- [end of lua code]

-- Open OBS Studio and create or select the desired scene.

-- Make sure you have set the name of your video/webcam source the same as the `local source_name` variable in the script.

-- Then, add in the script:

-- In the OBS Studio menu, go to 'Tools' > 'Scripts.'
-- Click the '+' button in the 'Scripts' window to add a new script.
-- Open the script (e.g., "ReloadWebcam.lua") and click 'Save.'
-- You should be all done!

I know this is an extremely "dumb" workaround for OBS's webcam freeze-up issues, but it might be of high use to some, since it pretty much solved all of my webcam freezing (Ubuntu 22.04, OBS Studio 29.0.2), especially the ones that usually happen over time.

I have been running it on a multi-webcam setup for hours now and I don't even notice any reload drop-outs when the camera source is reloaded. And yes, I've experienced this same freeze-up issue on multiple computers and multiple webcams over the years with OBS, even with high-end workstations.

I hope this is of help to you, since it finally seemed to have worked things out for me. *knocks on wood*

Let me know if there's any improvements that the script could use.

Cheers!
 

Carozene

New Member
Nitzz's diary update:

I've now run this new configuration for literally 24 hours over 3 days. There have been zero crashes. Again, my changes that have addressed the issue are I'm using a Thunderbolt 3 cable to USB C port instead of a standard USB C cable and I've upgraded to OBS 27.0.0 R2. While not specifically addressed in the release notes, one must wonder if this was it or using the Thunderbolt 3 cable (again, it's still using standard USB C ports on both ends, I've only used a Thunderbolt 3 cable). If it starts freezing again (especially since it's so random), I'll let y'all know and we'll try something else. For me, problem (potentially) resolved!
You made me realize I had the issue from the moment I switched cable from my cellphone fast charge usb cable I took temporarily when I purshed the camera to a cheap cable. It's just logical that the new cable being cheap is not "strong" enough for the high debit information and OBS doesn't like it. I switched back to my cellphone usb cable and the problem stopped. Thanks a lot!
 

Xexéo

New Member
Same problem here; even at 25 fps. It seems that it started happening (again) after a Windows update (KB2267602 version 1.387.2526.0), but not really sure.

09:54:00.356: [DShow Device: 'Video Capture Device'] settings updated:
09:54:00.356: video device: USB Camera
09:54:00.356: video path: \\?\usb#vid_0c45&pid_636b&mi_00#7&315a9f63&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global
09:54:00.356: resolution: 1920x1080
09:54:00.356: flip: 0
09:54:00.356: fps: 25.00 (interval: 400000)
09:54:00.356: format: MJPEG
09:54:00.356: buffering: disabled
09:54:00.356: hardware decode: disabled

Header for the log file

09:42:23.113: CPU Name: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
09:42:23.113: CPU Speed: 3392MHz
09:42:23.113: Physical Cores: 4, Logical Cores: 8
09:42:23.113: Physical Memory: 16353MB Total, 8424MB Free
09:42:23.114: Windows Version: 10.0 Build 19045 (release: 22H2; revision: 2846; 64-bit)
09:42:23.114: Running as administrator: false
09:42:23.114: Windows 10/11 Gaming Features:
09:42:23.114: Game Bar: On
09:42:23.114: Game DVR: On
09:42:23.114: Game DVR Background Recording: Off
09:42:23.114: Game Mode: Probably On (no reg key set)
09:42:23.118: Sec. Software Status:
09:42:23.127: Microsoft Defender Antivirus: enabled (AV)
09:42:23.128: Windows Firewall: enabled (FW)
09:42:23.129: Current Date/Time: 2023-04-28, 09:42:23
09:42:23.129: Browser Hardware Acceleration: true
09:42:23.129: Hide OBS windows from screen capture: false
09:42:23.129: Qt Version: 6.3.1 (runtime), 6.3.1 (compiled)
09:42:23.129: Portable mode: false
09:42:24.591: OBS 29.0.2 (64-bit, windows)
 

cygnus

New Member
I've got this same problem. I turned the FPS down to 30 but annoyingly the problem persists.
For now it can easily be temporarily fixed with the deactivate/activate source button, but a more permanent fix would be helpful.
Its entirely possible that this is a problem with some of my cords/connections. The problem only started a few weeks ago (after I fixed my last problem [stream feed flickering] by getting the latest OBS).
I don't know how that could be related, but it probably is since its only started since then.
Current settings are: video bitrate: 6800. 30 FPS.

The problem isn't terribly irritating---like I said, I can temporarily fix it. However, I often don't notice that it froze until 30 seconds to a few minutes after it started, since I am running church slides and streaming and have to switch between windows quite often.
Any help would be appreciated.
Thanks!
 

Attachments

  • 2024-01-14 09-11-56.txt
    50.9 KB · Views: 30

REDDDDY

New Member
I had the Problem with my Sony Alpha since i changed my graphic card. And i Finaly Know why.

Scroll down to " Advanced troubleshooting - Set PCIe to Gen3 "

Since i have the newGPU 3070 my Motherboard sets it Gen to Gen4 in Bios.
This is because the newgraphiccard run on this Gen. But it also could run smoothly on Gen3 so yeah after i changed the Bios from automatic to Gen3 i never had any freezing issues again.

I Think it also could be a Problem without elgaot cam link where you try to send a lot of video data through your USB and it is overloading.

What is your Motherboard / GPU setup from all of you who experiance this Problem?
Let me know if this hint could lead to an fix for you :)

Greetings
thank you for suggestions mister
 
Top