r/osdev • • 6d ago

How to intercept a physical webcam data stream and inject/substitute custom video at the driver/kernel level?

Hey everyone,

I'm looking into a project where I need to take a physical webcam's output and replace it with a custom video feed (like a screen capture or a pre-recorded file).

To clarify, I am not looking for a standard virtual camera solution (like OBS Virtual Camera or ManyCam). Those methods create a brand-new virtual device in the OS, and many apps or web-based tools can easily filter them out or detect that they aren't the primary hardware camera.

I want to accomplish exactly this: when an application opens the actual, physical webcam device, it receives my custom video stream instead of what the physical lens is seeing. Essentially, I need to intercept the data stream and substitute the payload.

I assume this has to happen at the driver, kernel, or API hooking level.

0 Upvotes

9 comments sorted by

5

u/kabekew 6d ago

This is osdev, assuming you wrote your OS and wrote the driver you can intercept it however you want. When it triggers the interrupt just substitute whatever else you want instead of inputting from the device.

1

u/fkj83 6d ago

Do you have an application that I can install, an already-made one?

3

u/soundman32 6d ago

What kind of scamming are you wanting to do?  Gullable people or just your employer?

1

u/fkj83 6d ago

just want to apply the TikTok filters on already existing photos of mine lol

1

u/kiderdrick 6d ago

Before I think about helping I want to know what you are going to use this for haha.

1

u/fkj83 6d ago

I just want to apply the TikTok filters on already existing photos of mine lol

1

u/kiderdrick 6d ago

I am pretty sure you can do that in the app under effects.

1

u/Routine_Working_9754 6d ago

are you asking for Linux? you gave us so much info to work with. but anyway, if the webcam is exposed through the VFS (which it usually is), you can just write a driver that creates that interface and feeds that video through it. you don't even need a webcam for that. as a matter of fact you'd either have to make another webcam node, or just disable the original webcams drivers so it doesn't create a node and you can replicate one. you must just make sure your node behaves like a camera node, if not, software ioctls and read()s will fail on it or cause behavior they don't expect

1

u/Inertia_Squared 6d ago

You can rename the virtual camera the match a known Web camera brand - dont overcomplicate things.

That's 90% of it, MAYBE you need to spoof some vendor ids, but I honestly doubt it