fix(launcher): check for ffmpeg only when starting screencast (#3874)
This commit is contained in:
parent
c20cbae529
commit
e5c6b19c00
|
|
@ -14,13 +14,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { launchProcess } from '../processLauncher';
|
||||
import { ChildProcess } from 'child_process';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { assert } from '../../utils/utils';
|
||||
import { launchProcess } from '../processLauncher';
|
||||
import { Progress, ProgressController } from '../progress';
|
||||
import * as types from '../types';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import { assert } from '../../utils/utils';
|
||||
import { spawnAsync } from '../validateDependencies';
|
||||
|
||||
const fps = 25;
|
||||
|
||||
|
|
@ -61,10 +62,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,
|
||||
|
|
|
|||
|
|
@ -115,8 +115,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.
|
||||
|
|
@ -236,17 +234,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 => {
|
||||
|
|
@ -439,6 +427,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',
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue