Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify capture window via CLI #3667

Open
domisjustanumber opened this issue Mar 12, 2024 · 2 comments
Open

Ability to specify capture window via CLI #3667

domisjustanumber opened this issue Mar 12, 2024 · 2 comments
Labels
enhancement Enhancement request

Comments

@domisjustanumber
Copy link

Is your feature request related to a problem? Please describe.
I am using CEF to host some JS code that processes a video feed with some machine vision tools, and the biggest hurdle we've run into is the only way to get video into CEF is via real or virtual webcams. This is a bit flakey and needs external software installing to work (SpoutCam or OBS).

It would be great if I could take advantage of Chrome's screen capture features to capture the contents of a specific window - it will be higher quality, not require any external tools to work, and hopefully much more reliable.

Describe the solution you'd like
I got very excited when I found --auto-select-window-capture-source-by-title as it's pretty much exactly what I'd like
https://peter.sh/experiments/chromium-command-line-switches/#auto-select-window-capture-source-by-title

Then when I do this:

let stream = await navigator.mediaDevices.getDisplayMedia({
        "video": {
          "displaySurface": "window"
        }
    },);

CEF would automatically share the window that had been specified via the CLI switch.

Right now it only seems to work for Chrome, but would be exactly what I want if it could be implemented in CEF as well. This would allow me to put the video content I want to capture in a window, shuffle it mostly off-screen, then use CEF to capture it without it having to take up screen real-estate.

Describe alternatives you've considered
Right now if I run that navigator.mediaDevices.getDisplayMedia command in CEF, all screens are shared, which seems to be due to this code which says "if no media ID is specified, share everything".

I'd hoped it might be possible to request a specific window or Media ID from the JS side, but for security reasons, it's also not possible for JS code to request a specific Window name in code.

Specifying the window to be shared in the CEF command line switch seems like the correct place to do this, and it would restrict what is shared right now vs. the entire desktop, so hopefully not an enhanced security concern.

I also considered WebRTC streaming into CEF, but it adds a lot of complexity, and importantly - a pretty big delay. As this is on the same machine, and low-latency interactivity is the goal, using screen capture instead is much more preferable.

Additional context
While not quite the same thing, this request seems to be related to specifying screen sharing sources in #3552

@magreenblatt
Copy link
Collaborator

This likely already works with Chrome runtime (cefclient --enable-chrome-runtime).

@domisjustanumber
Copy link
Author

domisjustanumber commented Mar 14, 2024

Ah alas I tested with CEF 122 and CEF 123.0.5. In both cases, adding --enable-chrome-runtime to both cefclient and cefsimple makes no difference to the screen sharing things - you still get all screens shared every time.

In some older versions (CEF 110 I believe) only a single monitor is shared if you just use the --use-fake-ui-for-media-stream, but it's not the window I was specifying with --auto-select-window-capture-source-by-title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement request
Projects
None yet
Development

No branches or pull requests

2 participants