Can I use a PowerShot Canon as a Webcam? - page 4 - Script Writing - CHDK Forum
supplierdeeply

Can I use a PowerShot Canon as a Webcam?

  • 38 Replies
  • 1580 Views
*

Offline reyalp

  • ******
  • 12586
Re: Can I use a PowerShot Canon as a Webcam?
« Reply #30 on: 19 / April / 2020, 16:51:45 »
Advertisements
BTW how can I keep chdk settings even when I install a new version?
The settings are in the .CFG files in the CHDK directory. If you just unzip the new build onto your card, they should normally be kept.  You can also save the files on your PC and copy them back later.
Don't forget what the H stands for.

*

Offline Ant

  • ****
  • 440
Re: Can I use a PowerShot Canon as a Webcam?
« Reply #31 on: 26 / April / 2020, 03:16:55 »
@srsa_4c @reyalp

How about reprogramming the USB port on Canon cameras so that it works like a WebCam instead of PTP?
I found an implementation of USB Video Class that looks simple.

But we need to work on lower levels to do these things:
1. Modifying USB descriptors from PTP to UVC.
2. Handling standard and class specific USB requests.
3. Streaming video data through Bulk IN endpoint(preferably using DMA).

Tasks 2 and 3 require additional knowledge of USB hardware on Digic processors.
Do you have an idea how to do this?

*

Offline reyalp

  • ******
  • 12586
Re: Can I use a PowerShot Canon as a Webcam?
« Reply #32 on: 26 / April / 2020, 03:52:15 »
@srsa_4c @reyalp

How about reprogramming the USB port on Canon cameras so that it works like a WebCam instead of PTP?
I found an implementation of USB Video Class that looks simple.

But we need to work on lower levels to do these things:
1. Modifying USB descriptors from PTP to UVC.
Unless you make it appear as a composite device and support both (likely much more complicated), you lose PTP control which would be somewhat annoying.

Quote
2. Handling standard and class specific USB requests.
3. Streaming video data through Bulk IN endpoint(preferably using DMA).

Tasks 2 and 3 require additional knowledge of USB hardware on Digic processors.
Do you have an idea how to do this?
Not really. There are certainly hints in the firmware, but it involves a lot of code. Note that in factory mode, the cameras show up as some kind of non-PTP device (edit: or at least old ones did), so that might provide some hints.

My preferred approach for webcam support would be to use the existing PTP protocol and feed live view data to some kind of dummy/loopback device. Linux already has this kind of capability with v4l2loopback, which you could theoretically feed piping lvdumpimg to ffmpeg, but would need some more glue to do in the background while also using chdkptp. On windows, you'd probably need something similar to https://obsproject.com/forum/resources/obs-virtualcam.539/ (or use the chdkptp window as an OBS source and use that...)

Of course, someone who is a reverse engineering whiz with good knowledge of USB might prefer to implement it on the camera.
« Last Edit: 26 / April / 2020, 04:11:39 by reyalp »
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4229
Re: Can I use a PowerShot Canon as a Webcam?
« Reply #33 on: 26 / April / 2020, 07:55:09 »
I have no deep knowledge of USB unfortunately and the firmwares do not include lots of USB-related debug strings either, so it's a difficult subject. So, as reyalp said, making a Windows-compatible webcam out of these cameras is more like a Windows-side project (making an app and/or driver).


*

Offline reyalp

  • ******
  • 12586
Re: Can I use a PowerShot Canon as a Webcam?
« Reply #34 on: 26 / April / 2020, 16:49:20 »
Some things that would be useful regardless of transport:
* Reversing the mjpeg encoder that Canon's own live view protocol appears to have used. I suspect they still use this for the apps that support remote shooting, but haven't investigated. Or the regular video encoders, but I suspect that would be more difficult.
* Some way to synchronize frames more closely with camera refresh. For the existing PTP protocol, I've thought about adding an option that signals "only new frames" and then tracking when the live view pointer changes, or hooking into whatever timer drivers refresh. You'd still have polling overhead, but could avoid receiving duplicate frames. OTOH, the current chdkptp implementation has trouble pulling >25 FPS so duplicate frames are probably not a major issue.
* Ability to get the most recent complete buffer, rather than the partial buffer used by vid_get_viewport_live_fb (see https://chdk.setepontos.com/index.php?topic=14022.10). I believe the field identified as current_viewport_buffer on digic 6 holds this, exists on earlier cams, and could probably be found by the sigfinders.

There are a number of "virtual webcam" type apps for windows, mostly commercial. From google, manycam, magic camera and vcam appear to have this capability. See also https://alax.info/blog/1626
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4229
Re: Can I use a PowerShot Canon as a Webcam?
« Reply #35 on: 26 / April / 2020, 16:59:36 »
* Reversing the mjpeg encoder that Canon's own live view protocol appears to have used. I suspect they still use this for the apps that support remote shooting, but haven't investigated. Or the regular video encoders, but I suspect that would be more difficult.
New cameras that have native remote live view use the h264 encoder for the video stream. Which causes the unfortunate limitation that recording videos is not supported while using remote live view. I have no idea why they don't allow mjpeg  compression as the good old jpeg engine is still there.

*

Offline reyalp

  • ******
  • 12586
Re: Can I use a PowerShot Canon as a Webcam?
« Reply #36 on: 28 / April / 2020, 19:40:44 »
Related ;)

Canon's new software will turn select EOS, PowerShot cameras into webcams for Windows 10 PCs

Only current, high end cams. Interestingly, it doesn't appear to be a firmware update, so presumably using existing camera side capability.
Don't forget what the H stands for.

Re: Can I use a PowerShot Canon as a Webcam?
« Reply #37 on: 29 / April / 2020, 10:16:58 »
Seems to be part of a new initiative from Canon? More here : https://fstoppers.com/software/will-new-software-canon-change-future-photography-479325
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline Ant

  • ****
  • 440
Re: Can I use a PowerShot Canon as a Webcam?
« Reply #38 on: 17 / May / 2020, 16:17:47 »
Some progress with USB Video Class implementation:
I changed USB descriptors and patched TrnsCtrlTask to handle UVC specific requests. Now EOS M3 camera is recognised as webcam.
But next problem is streaming Video data through bulk data pipe.
If I understand correctly, in PTP mode BulkIn transfers are initiated by USB Host.
There need to force the camera to sending data by itself.
How to do that?

 

Related Topics