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

Can't fake video for webcam testing #29348

Open
iuliaib opened this issue Apr 17, 2024 · 1 comment
Open

Can't fake video for webcam testing #29348

iuliaib opened this issue Apr 17, 2024 · 1 comment
Labels
stage: needs investigating Someone from Cypress needs to look at this

Comments

@iuliaib
Copy link

iuliaib commented Apr 17, 2024

Current behavior

Hello! I am new to Cypress and I am trying to send an *.y4m video to the webcam.
I have a Typescript project.

I've found this project on github: https://github.com/taylorjg/sudoku-buster-react and here is working to fake the webcam (I've also updated to the latest cypress version and is still working), but if I replace the baseUrl with my project's one, no video is loading. This is what I get:
fake-video-not-working

Does anyone have any idea why the *.y4m video is not played? (I've also tried other extensions as *.mjpeg, but I have the same behaviour)

As the BE & FE projects are on some private repositories, I will send here pieces of code when asked.

Here is the DOM of my webcam-page: dom-page.txt

webcam

Desired behavior

I am expecting to see the *.y4m video as per:

Test code to reproduce

I have also tried to use "cypress-browser-permissions": "^1.1.0", but it didn't make any difference:

// cypress.config.ts

  env: {
    browserPermissions: {
      camera: 'allow',
      image: 'allow'
    }
  },

  e2e: {
    baseUrl: process.env.BASE_URL ?? 'http://localhost:3000',

    setupNodeEvents(on: Cypress.PluginEvents, _config: Cypress.PluginConfigOptions): void {
      on('before:browser:launch', (_browser: Cypress.Browser, launchOptions: Cypress.BeforeBrowserLaunchOptions) => {
        _config = cypressBrowserPermissionsPlugin(on, _config);

        launchOptions.args.push(`--use-fake-ui-for-media-stream`);
        launchOptions.args.push(`--use-fake-device-for-media-stream`);
        launchOptions.args.push('--use-file-for-fake-video-capture=cypress/fixtures/qrCodeTest.y4m');
        return launchOptions;
      });
    }
  }

Chrome: Version 123.0.6312.122 (Official Build) (64-bit)

All the other configurations are in the attached GitHub project

Cypress Version

13.7.3

Node version

v21.6.1

Operating System

Ubuntu 20.04

Debug Logs

No response

Other

No response

@jennifer-shehane jennifer-shehane added the stage: needs investigating Someone from Cypress needs to look at this label Apr 19, 2024
@thevladisss
Copy link

So what worked for me in this case is that I had to properly format video for ".y4m" format, which I achieved via "ffmpeg -i test.mp4 -pix_fmt yuv420p test.y4m" command. (make sure to install to have ffmpeg installed
Also make sure that your browser persmissions plugin enables permissions for camera for Chrome, you can make sure you actually have --use-fake-device-for-media-stream and --use-fake-device-for-media-stream set by logging permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this
Projects
None yet
Development

No branches or pull requests

3 participants