1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

playwrightでテストする際、物理カメラがないのでwebcamに動画を流したい

Posted at

問題

playwrightが操作するchromeとかはplaywrightが自前でインストールするもので、物理カメラがない(更に自分はdocker化している)

解決

playwright.config.ts にlaunchOptionsを追加する。この際に必要なのが.y4m拡張子か.mjpeg拡張子の動画

The supported file formats are YUV4MPEG2 (a.k.a. Y4M) and MJPEG/JPEG

自分はiPhoneにあった動画をffmpegで.mjepgに変換した

$ ffmpeg -i iPhone.MOV sample.mjpeg

その上でlaunchOptionsのargsにこのように設定

import { PlaywrightTestConfig } from "@playwright/test"
const config: PlaywrightTestConfig = {
  use: {
    launchOptions: {
      args: [
        "--use-fake-ui-for-media-stream",
        "--use-fake-device-for-media-stream",
        "--use-file-for-fake-video-capture=/app/sample.mjpeg",
      ],
    },
  },
}
export default config

--use-fake-ui-for-media-streamは合わせて使うという事が書かれているページは見なかったが、自分の場合はこの3つを合わせないとだめだった
使っているパッケージの問題なのか、最近のchromeでの違いなのか...

  • --use-fake-ui-for-media-stream
  • --use-fake-device-for-media-stream
  • --use-file-for-fake-video-capture=/app/sample.mjpeg

使っていたパッケージ

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?