secile / UsbCamera

C# source code for using usb camera and web camera in WinForms/WPF. With only single CSharp source code. No external library required.
MIT License
179 stars 55 forks source link

需要增加对于部分非标的虚拟摄像头的过滤(It is necessary to increase the filtering of some non-standard virtual cameras) #25

Closed yangjieshao closed 1 year ago

yangjieshao commented 1 year ago
  1. 下载并安装 非标的虚拟摄像头(例如 YY开播) (Download and install non-standard cameras such as 'YY开播') YY开播

  2. FindDevices 成功获取到 ‘YY开播’ (find 'YY开播’ success by FindDevices ) image

  3. GetVideoFormat 时报错 (error on GetVideoFormat ) image

造成这个的原因是 ‘YY开播’ 注册了一个信息不完整的USB摄像头 (The reason for this is that a USB camera with incomplete information has been registered by 'YY开播')

问题是我们没办法限制用户不要安装什么软件 (The problem is that we can't restrict users from installing any software)

我发现在 GetFiltes 时 'YY开播' 无法获取到 DevicePath (I found that 'YY开播' could not get DevicePath when GetFiltes) image

所以 尝试获取 DevicePath 或许是一个过滤非标虚拟摄像头的方式 (So trying to get DevicePath may be a way to filter non-standard virtual cameras)


我发现 FlashCap 并没有这个问题,他直接就过滤了非标的虚拟USB摄像头信息 (I found that FlashCap did not have this problem. It directly filtered the non-standard virtual USB camera information)

DirectShowDevices.cs

secile commented 1 year ago

Hello. Thank you for your information.

I want to confirm. please let me know.

Does problem is exception happens when FindDevices()? It is not problem that you can not use not non-standard cameras such as 'YY开播'?

In general, virtual camera has to implement IAmStreamConfig interface, but it seems that 'YY开播' do not have the IAmStreamConfig interface. so I think it is difficult to use 'YY开播' as a virtual camera.

yangjieshao commented 1 year ago

仅仅获取 FriendlyName 是不报异常的 (Only getting FriendlyName is ok)

只有在获取 DevicePath 的时候会报异常 (An exception will be reported only when get DevicePath)

过滤并忽略'YY开播'是可接受的 (It is acceptable to filter and ignore 'YY开播')


事实上 这确实是'YY开播'在实现USB摄像头时并未按照标准实现产生的bug (In fact, this is really a bug that 'YY开播' did not implement USB camera according to the standard)

‘YY开播’这样实现的原因可能是因为他并不想其它软件使用他的图片流 (The reason for 'YY开播' to achieve this may be that they do not want other software to use their image stream)

但是我们并不能保证所有的第三方厂商的实现都是标准的 (However, we cannot guarantee that all third-party implementations are standard)

对于那些不标准的实现,我们至少要做到不暴露异常给最终用户 (For those non-standard implementations, we should at least not expose exceptions to end users)

对于这种不标准实现,我的建议是直接过滤不显示 (For this non-standard implementation, my suggestion is to filter directly and not display)

这样用户就不会去选择使用这个不标准的摄像头 (So users will not choose to use this non-standard camera)

也就不会出现播放视频失败的现象 (So will be no failure to play video)


you can download YY开播 image

虽然 抖音'直播伴侣'可以使用'YY开播'的视频流 (Although Tiktok '直播伴侣' can use 'YY开播' video streams)

应该是抖音做了额外的开发 (It should be that Tiktok has made additional development)

直播伴侣 image

secile commented 1 year ago

Hello, sorry for late reply.

To tell the truth, I couldn’t understand what is a problem. I tried to download ‘YY开播’, but I can’t use it because I can’t read Chinese. But, I finally understand.

You are saying that, virtual camera such as ‘YY开播’ successes FindDevices, But do not successes GetVideoFormat and do not work correctly. So it should not be shown by FindDevices.

As to this problem, I will not filter ‘YY开播’ to disable, but let ‘YY开播’ works in default video format.

If you still have this problem, could you test it? UsbCameraIssue#25.zip

yangjieshao commented 1 year ago

thanks

wxharry commented 8 months ago

I have a related problem with the virtual camera, I installed obs on my machine and it is detected as a device but it cannot work properly.

wxharry commented 8 months ago

I have a related problem with the virtual camera, I installed obs on my machine and it is detected as a device but it cannot work properly.

I found get DevicePath throws an error on the virtual camera which is a way to filter it out. However, it throws an error. Alternatively, you can add [PreserveSig] to the read method and compare the output to filter out virtual cameras.

secile commented 7 months ago

@wxharry Hello, thank you for your information. I confirmed that obs virtual camera do not work with my library, but Microsoft Teams app is able to use obs virtual camera. I do not know why, but In my estimation, obs virtual camera must be used with obs studio and app that uses virtual camera at a same time, but my library is based on DirectShow, and DirectShow can not use camera at a same time from different app. Teams may not use DirectShow, but use more modern technology, I think.