Inconsistent device IDs causing "device or resource busy"

jbrains

New Member
Such fun!

OBS Studio is occasionally becoming confused by my camera devices, because the device ID (`/dev/video*`) changes from time to time, so that the mapping from sources in OBS Studio to underlying video devices is not stable. This caused me to deal with "device or resource busy" today, when my "Tablet" OBS Studio source was mapped to my external webcam, not the USB video capture card to which my tablet was attached. Consequently, when I switched to the scene for my external webcam, I saw nothing but black, and in the logs, I saw "device or resource busy".

I presume that this is due to Pop!_OS not using stable `/dev/video*` device IDs for my various video devices, but I might have that wrong.

What can I do about this? other than play musical chairs with my video sources?
 

AaronD

Active Member
Ubuntu Studio here. No experience with Pop!_OS at all, so it might be completely different. But anyway, what determines the assignments for me is the order that they enumerate. No fixed assignments. So the key then, is to make sure that everything enumerates in the same order every time, and then it "just works" like you expect.

Either *always* have everything plugged in on a cold startup (shutdown completely if you have to, and start back up again), or *always* have the external stuff unplugged on startup and then plug in in the same order every time.

What often got me too, was OBS's virtual camera, which takes another assignment just like a physical capture. And it wanted my password to turn on because that has to be done as root. So I found the line in OBS's source code that does that if it isn't already, and copy/pasted it into a script that runs as root on startup. So that's always running even before I start OBS, and OBS just grabs it. No more password prompt.
And I added an explicit assignment, to keep it away from the automatic ones, so that it doesn't affect them anymore anyway.
Bash:
modprobe v4l2loopback exclusive_caps=1 card_label='OBS Virtual Camera' video_nr=99
 

jbrains

New Member
Ubuntu Studio here. No experience with Pop!_OS at all, so it might be completely different. But anyway, what determines the assignments for me is the order that they enumerate. No fixed assignments. So the key then, is to make sure that everything enumerates in the same order every time, and then it "just works" like you expect.

Either *always* have everything plugged in on a cold startup (shutdown completely if you have to, and start back up again), or *always* have the external stuff unplugged on startup and then plug in in the same order every time.

What often got me too, was OBS's virtual camera, which takes another assignment just like a physical capture. And it wanted my password to turn on because that has to be done as root. So I found the line in OBS's source code that does that if it isn't already, and copy/pasted it into a script that runs as root on startup. So that's always running even before I start OBS, and OBS just grabs it. No more password prompt.
And I added an explicit assignment, to keep it away from the automatic ones, so that it doesn't affect them anymore anyway.
Bash:
modprobe v4l2loopback exclusive_caps=1 card_label='OBS Virtual Camera' video_nr=99
Thank you for confirming this workaround.

For other bystanders, is there some way to "reserve" video device IDs through configuration, similar to how one can reserve IP addresses for devices in a DHCP server? I recognize that this is a general Ubuntu or Linux question, and not an OBS Studio question, although it seems relevant to OBS Studio users.
 
Top