Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
Recommend @ffmpeg-installer/ffmpeg instead of ffmpeg-static
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Davis committed Jun 1, 2020
1 parent d2533c6 commit 55ddec0
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 131 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ When Playwright adds support for the Screencast API in Firefox and WebKit, this
## Install

```sh
npm i playwright playwright-video ffmpeg-static
npm i playwright playwright-video @ffmpeg-installer/ffmpeg
```

If you already have [FFmpeg](https://www.ffmpeg.org) installed, you can skip the `ffmpeg-static` installation by setting the `FFMPEG_PATH` environment variable.
If you already have [FFmpeg](https://www.ffmpeg.org) installed, you can skip the `@ffmpeg-installer/ffmpeg` installation by setting the `FFMPEG_PATH` environment variable.

```sh
npm i playwright playwright-video
Expand Down
182 changes: 60 additions & 122 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"tslib": "^2.0.0"
},
"devDependencies": {
"@ffmpeg-installer/ffmpeg": "^1.0.20",
"@types/debug": "^4.1.5",
"@types/fluent-ffmpeg": "^2.1.14",
"@types/fs-extra": "^9.0.1",
Expand All @@ -50,7 +51,6 @@
"eslint": "^7.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jest": "^23.13.2",
"ffmpeg-static": "^4.2.2",
"jest": "^26.0.1",
"np": "^6.2.3",
"playwright": "^1.0.2",
Expand Down
8 changes: 5 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { ChromiumBrowserContext, Page } from 'playwright-core';

export const getFfmpegFromModule = (): string | null => {
try {
const ffmpegPath = require('ffmpeg-static'); // eslint-disable-line @typescript-eslint/no-var-requires
if (ffmpegPath) return ffmpegPath;
const ffmpeg = require('@ffmpeg-installer/ffmpeg'); // eslint-disable-line @typescript-eslint/no-var-requires
if (ffmpeg.path) {
return ffmpeg.path;
}
} catch (e) {} // eslint-disable-line no-empty

return null;
Expand All @@ -22,7 +24,7 @@ export const ensureFfmpegPath = (): void => {
const ffmpegPath = getFfmpegPath();
if (!ffmpegPath) {
throw new Error(
'pw-video: FFmpeg path not set. Set the FFMPEG_PATH env variable or install ffmpeg-static as a dependency.',
'pw-video: FFmpeg path not set. Set the FFMPEG_PATH env variable or install @ffmpeg-installer/ffmpeg as a dependency.',
);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ describe('getFfmpegPath', () => {
process.env.FFMPEG_PATH = '';
});

it('returns ffmpeg-static path if installed', () => {
it('returns @ffmpeg-installer/ffmpeg path if installed', () => {
jest
.spyOn(utils, 'getFfmpegFromModule')
.mockReturnValue('ffmpeg-static/path');
.mockReturnValue('@ffmpeg-installer/ffmpeg/path');

const path = getFfmpegPath();
expect(path).toBe('ffmpeg-static/path');
expect(path).toBe('@ffmpeg-installer/ffmpeg/path');
});

it('returns null when no path is found', () => {
Expand Down

0 comments on commit 55ddec0

Please sign in to comment.