Skip to content

Commit

Permalink
pull ffmpeg executable base name from package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Dec 2, 2022
1 parent ffd969f commit a43ff37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ if (process.env.FFMPEG_BIN) {
} else {
var os = require('os')
var path = require('path')
const pkg = require('./package.json')
const {
'executable-base-name': executableBaseName,
} = pkg[pkg.name]
if ('string' !== typeof executableBaseName) {
throw new Error(`package.json: invalid/missing ${pkg.name}.executable-base-name entry`)
}

var binaries = Object.assign(Object.create(null), {
darwin: ['x64', 'arm64'],
Expand All @@ -18,7 +25,7 @@ if (process.env.FFMPEG_BIN) {

var ffmpegPath = path.join(
__dirname,
platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'
executableBaseName + (platform === 'win32' ? '.exe' : ''),
)

if (!binaries[platform] || binaries[platform].indexOf(arch) === -1) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"ffmpeg-static": {
"binary-release-tag-env-var": "FFMPEG_BINARY_RELEASE",
"binary-release-tag": "b5.0.1",
"binaries-url-env-var": "FFMPEG_BINARIES_URL"
"binaries-url-env-var": "FFMPEG_BINARIES_URL",
"executable-base-name": "ffmpeg"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit a43ff37

Please sign in to comment.