ulixee / hero

The web browser built for scraping
MIT License
647 stars 32 forks source link

How to replace chrome camera feed with a media file. #234

Open DarkFunct opened 11 months ago

DarkFunct commented 11 months ago

I want to be able to replace my Chrome camera feed with media files, can you help me? Similar to:

google-chrome --use-fake-device-for-media-stream --use-file-for-fake-video-capture=YOUR-FILE-HERE.y4m

Thank you so much.

blakebyrnes commented 11 months ago

You can do that with a plug-in that implements the onNewBrower function.

https://ulixee.org/docs/hero/plugins/core-plugins

DarkFunct commented 11 months ago

Ok,Thank.

const options = '--use-fake-device-for-media-stream --use-file-for-fake-video-capture=YOUR-FILE-HERE.y4m';
configureBrowserLaunchArgs(browser.engine, options);
blakebyrnes commented 11 months ago

You're looking in the right place, but that's not the plugin spec. You need to build a plugin (like the core plugin here ), and add an onNewBrowser, like so:

onNewBrowser(browser) {
      browser.engine.launchArguments.push('--use-fake-device-for-media-stream --use-file-for-fake-video-capture=YOUR-FILE-HERE.y4m');
 },

If you want'ed to make the file variable, you might add a client api like the execute js plugin (https://github.com/ulixee/hero/blob/main/plugins/execute-js/lib/ClientPlugin.ts)

DarkFunct commented 11 months ago

Ok! I'll try to verify it.