Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions src/server/chromium/videoRecorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
* limitations under the License.
*/

import { launchProcess } from '../processLauncher';
import { ChildProcess } from 'child_process';
import { Progress, runAbortableTask } from '../progress';
import * as types from '../types';
import * as path from 'path';
import * as os from 'os';
import * as path from 'path';
import { assert } from '../../utils/utils';
import { launchProcess } from '../processLauncher';
import { Progress, runAbortableTask } from '../progress';
import * as types from '../types';
import { spawnAsync } from '../validateDependencies';

const fps = 25;

Expand Down Expand Up @@ -59,10 +60,16 @@ export class VideoRecorder {

let ffmpegPath = 'ffmpeg';
const binPath = path.join(__dirname, '../../../third_party/ffmpeg/');
if (os.platform() === 'win32')
if (os.platform() === 'win32') {
ffmpegPath = path.join(binPath, os.arch() === 'x64' ? 'ffmpeg-win64.exe' : 'ffmpeg-win32.exe');
else if (os.platform() === 'darwin')
} else if (os.platform() === 'darwin') {
ffmpegPath = path.join(binPath, 'ffmpeg-mac');
} else {
// Look for ffmpeg in PATH.
const {code, error} = await spawnAsync(ffmpegPath, ['-version'], {});
if (code !== 0 || error)
throw new Error('ffmpeg not found.\nInstall missing packages with:\n sudo apt-get install ffmpeg');
}
const { launchedProcess, gracefullyClose } = await launchProcess({
executablePath: ffmpegPath,
args,
Expand Down
16 changes: 1 addition & 15 deletions src/server/validateDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ 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.
Expand Down Expand Up @@ -233,17 +231,7 @@ async function missingDLOPENLibraries(browser: BrowserDescriptor): Promise<strin
return 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}> {
export function spawnAsync(cmd: string, args: string[], options: any): Promise<{stdout: string, stderr: string, code: number, error?: Error}> {
const process = spawn(cmd, args, options);

return new Promise(resolve => {
Expand Down Expand Up @@ -436,6 +424,4 @@ const MANUAL_LIBRARY_TO_PACKAGE_NAME_UBUNTU: { [s: string]: string} = {
// and if it's missing recommend installing missing gstreamer lib.
// gstreamer1.0-libav -> libavcodec57 -> libx264-152
'libx264.so': 'gstreamer1.0-libav',
// Required for screencast in Chromium.
'ffmpeg': 'ffmpeg',
};