What is required from a device to be read in a WebcamTexture?

Hello

I created a directshow filter to create a virtual webcam device. It works with most software (VLC, Virtools, GraphEdit). But when I try to use it in Unity with WebcamTexture, it doesn’t works.

  • The device is present in the array provided by WebcamTexture.devices

  • Creation of the WebcamTexture works. (For information, if I tried to create a WebcamTexture with an invalid device name, I would get this error : Cannot find webcam device BadName.)

  • When I try to use myWebCamTexture.Play() , I get this error :

    ERROR - Could not find specified video device

So, Unity sees my device (it appears in WebcamTexture.devices) but seems unable to use it. Why?

The very same scipt works perfectly with real webcams, and with other virtual cams (ex : e2esoft VCam).

I know this is a very specific question, but does anyone knows how does Unity handle webcam? (in particular, what in the difference with how other softwares handle it).

Edit :

My directshow filter implement these interfaces

  • IAMStreamConfig
  • IBaseFilter
  • IKsPropertySet
  • IMediaFilter
  • IPersist
  • ISpecifyPropertyPages

While another directshow filter (e2esoft vcam) that works within Unity implement these ones :

  • IAMFilterMiscFlags
  • IAMVideoControl
  • IAMVideoProcAmp
  • IBaseFilter
  • IKSPropertySet
  • IMediaFilter
  • IMediaSeeking
  • IPersist
  • IPersistStream
  • ISpecifyPropertyPages

In bold are the interfaces that are missing in my filter. Are these all required to be used as webcam by Unity? Or do I only need to implement a specific one?

Sorry for bumping an old thread but in case anyone else runs into this issue here’s a solution that worked for me.

Unity appears to use a library called VideoInput.

This checks for a Device Path. You can add one to your filter’s registry entry during DllRegisterServer using the code snippet from this blog.

This adds a subkey called DevicePath with value of “foo:bar” (a dummy device path is fine).

Once I did this my filter was correctly showing in Unity.