Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat(screencast): use system ffmpeg on linux (#3724)
Yury Semikhatskyfc296235080a
diff --git a/.github/workflows/infra.yml b/.github/workflows/infra.ymlindex 8eccd7b369..7523e3d887 100644--- a/.github/workflows/infra.yml+++ b/.github/workflows/infra.yml@@ -24,6 +24,7 @@ jobs:sudo apt-get updatesudo apt-get install libgbm-devsudo apt-get install xvfb+ sudo apt-get install ffmpeg- run: npm ci- run: npm run build- run: npm run lintdiff --git a/src/server/chromium/videoRecorder.ts b/src/server/chromium/videoRecorder.tsindex da50437879..9c4fd1a2e5 100644--- a/src/server/chromium/videoRecorder.ts+++ b/src/server/chromium/videoRecorder.ts@@ -14,7 +14,6 @@* limitations under the License.*/-const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;import { launchProcess } from '../processLauncher';import { ChildProcess } from 'child_process';import { Progress, runAbortableTask } from '../progress';@@ -55,6 +54,8 @@ export class VideoRecorder {const args = `-f image2pipe -c:v mjpeg -i - -y -an -r ${fps} -c:v vp8 -vf pad=${w}:${h}:0:0:gray,crop=${w}:${h}:0:0`.split(' ');args.push(options.outputFile);const progress = this._progress;+ // Use ffmpeg provided by the host system.+ const ffmpegPath = process.platform === 'linux' ? 'ffmpeg' : require('@ffmpeg-installer/ffmpeg').path;const { launchedProcess, gracefullyClose } = await launchProcess({executablePath: ffmpegPath,args,diff --git a/src/server/validateDependencies.ts b/src/server/validateDependencies.tsindex 734a1e921a..98a4193c5e 100644--- a/src/server/validateDependencies.ts+++ b/src/server/validateDependencies.ts@@ -112,6 +112,8 @@ async function validateDependenciesLinux(browserPath: string, browser: BrowserDe}for (const dep of (await missingDLOPENLibraries(browser)))missingDeps.add(dep);+ for (const dep of (await missingSystemBinaries(browser)))+ missingDeps.add(dep);if (!missingDeps.size)return;// Check Ubuntu version.@@ -231,6 +233,16 @@ async function missingDLOPENLibraries(browser: BrowserDescriptor): Promise<strinreturn libraries.filter(library => !isLibraryAvailable(library));}+async function missingSystemBinaries(browser: BrowserDescriptor): Promise<string[]> {+ if (browser.name !== 'chromium')+ return [];+ // Look for ffmpeg in PATH.+ const {code, error} = await spawnAsync('ffmpeg', ['-version'], {});+ if (code !== 0 || error)+ return ['ffmpeg'];+ return [];+}+function spawnAsync(cmd: string, args: string[], options: any): Promise<{stdout: string, stderr: string, code: number, error?: Error}> {const process = spawn(cmd, args, options);@@ -423,5 +435,7 @@ const MANUAL_LIBRARY_TO_PACKAGE_NAME_UBUNTU: { [s: string]: string} = {// in the ldconfig cache, so we detect the actual library required for playing h.264// and if it's missing recommend installing missing gstreamer lib.// gstreamer1.0-libav -> libavcodec57 -> libx264-152- 'libx264.so': 'gstreamer1.0-libav'+ 'libx264.so': 'gstreamer1.0-libav',+ // Required for screencast in Chromium.+ 'ffmpeg': 'ffmpeg',};