Skip to content

Commit

Permalink
Merge pull request #12 from sergiu-omg/replace-deprecated-package-ffm…
Browse files Browse the repository at this point in the history
…peg-binaries

Replaces deprecated package 'ffmpeg-binaries' with drop-in replacement 'ffmpeg-static'
  • Loading branch information
Thiago authored Feb 16, 2021
2 parents 2976397 + 9f4668f commit 7ab67f3
Show file tree
Hide file tree
Showing 5 changed files with 473 additions and 479 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Make sure you have [ffmpeg](https://ffmpeg.org/) installed and added to your pat
npm install [-g] media-split
```

If you don't have ffmpeg installed, you can install [this](https://www.npmjs.com/package/ffmpeg-binaries) or [this](https://www.npmjs.com/package/@ffmpeg-installer/ffmpeg) package which
If you don't have ffmpeg installed, you can install [this](https://www.npmjs.com/package/ffmpeg-static) or [this](https://www.npmjs.com/package/@ffmpeg-installer/ffmpeg) package which
comes with a bundled ffmpeg, and media-split will automatically detect and use it.

```bash
npm install [-g] ffmpeg-binaries
npm install [-g] ffmpeg-static
```
or
```bash
Expand Down
4 changes: 2 additions & 2 deletions lib/FFmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function global (lib) {
const libs = {
// local installation
'@ffmpeg-installer/ffmpeg': (lib) => require(lib).path,
'ffmpeg-binaries': (lib) => require(lib),
'ffmpeg-static': (lib) => require(lib),
ffmpeg: (lib) => {
const proc = spawnSync(lib)
if (proc.error instanceof Error) {
Expand All @@ -21,7 +21,7 @@ const libs = {
}
},
[ global('@ffmpeg-installer/ffmpeg') ]: (lib) => require(lib).path,
[ global('ffmpeg-binaries') ]: (lib) => require(lib)
[ global('ffmpeg-static') ]: (lib) => require(lib)
}

module.exports = null
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"miniget": "^2.0.1",
"sanitize-filename": "^1.6.3",
"yargs": "^15.4.1",
"ytdl-core": "^3.2.2"
"ytdl-core": "^4.4.5"
},
"peerDependencies": {
"ffmpeg-binaries": "^4.0.0",
"@ffmpeg-installer/ffmpeg": "^1.0.20"
"@ffmpeg-installer/ffmpeg": "^1.0.20",
"ffmpeg-static": "^4.2.7"
},
"bin": {
"mp3-split": "cli/index.js",
Expand Down
14 changes: 7 additions & 7 deletions spec/FFmpeg.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ describe('FFmpeg', function () {
expect(require1).to.be.equals('foo')
})

it('should fallback to ffmpeg-binaries', function () {
it('should fallback to ffmpeg-static', function () {
mockRequire('@ffmpeg-installer/ffmpeg', errorModule)
mockRequire('ffmpeg-binaries', 1)
mockRequire('ffmpeg-static', 1)
const require1 = require(moduleName)
expect(require1).to.be.equals(1)
})

it('should fallback to ffmpeg on $PATH', function () {
let called = false
mockRequire('@ffmpeg-installer/ffmpeg', errorModule)
mockRequire('ffmpeg-binaries', errorModule)
mockRequire('ffmpeg-static', errorModule)
childProcess.spawnSync = function (cmd) {
called = true
expect(cmd).to.be.equals('ffmpeg')
Expand All @@ -48,18 +48,18 @@ describe('FFmpeg', function () {

it('should fallback to global @ffmpeg-installer', function () {
mockRequire('@ffmpeg-installer/ffmpeg', errorModule)
mockRequire('ffmpeg-binaries', errorModule)
mockRequire('ffmpeg-static', errorModule)
childProcess.spawnSync = errorSpawn
mockRequire(path.join(global, '@ffmpeg-installer/ffmpeg'), { path: 'qux' })
expect(require(moduleName)).to.be.equals('qux')
})

it('should fallback to global ffmpeg-binaries', function () {
it('should fallback to global ffmpeg-static', function () {
mockRequire('@ffmpeg-installer/ffmpeg', errorModule)
mockRequire('ffmpeg-binaries', errorModule)
mockRequire('ffmpeg-static', errorModule)
childProcess.spawnSync = errorSpawn
mockRequire(path.join(global, '@ffmpeg-installer/ffmpeg'), errorModule)
mockRequire(path.join(global, 'ffmpeg-binaries'), 2)
mockRequire(path.join(global, 'ffmpeg-static'), 2)
expect(require(moduleName)).to.be.equals(2)
})

Expand Down
Loading

0 comments on commit 7ab67f3

Please sign in to comment.