Skip to content

Use custom shared libraries from ffmpeg-build-scripts fork instead of homebrew #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
32e2bc0
use custom shared libraries from ffmpeg-build-scripts fork instead of…
srubin Dec 4, 2020
ad7affc
add ffmpegPath and ffprobePath on main module
srubin Dec 4, 2020
ea2073f
include dirs
srubin Dec 4, 2020
8fc1d70
skip arm64 build
srubin Dec 4, 2020
c664534
rc10
srubin Dec 4, 2020
197bd19
handle symlinks when unzipping
srubin Dec 4, 2020
3f208f5
Update package.json
srubin Dec 4, 2020
efd48ca
skip prebuild install when trying to build the prebuilds :-)
srubin Dec 4, 2020
b3e2df5
Update package.json
srubin Dec 4, 2020
cbfa835
Update package.json
srubin Dec 4, 2020
e5ff233
Update package.json
srubin Dec 4, 2020
494e69f
patch-package is dev dep
srubin Dec 4, 2020
4565bcd
dev patch-packages
srubin Dec 4, 2020
d952d44
paths entry point
srubin Dec 4, 2020
493a186
path types
srubin Dec 4, 2020
a125412
Update package.json
srubin Dec 4, 2020
4a47ebe
fixes
srubin Dec 4, 2020
4eeb60d
version bump
srubin Dec 4, 2020
83ab2ec
don't patch-package for normal install
srubin Dec 4, 2020
1c4444f
Update package.json
srubin Dec 4, 2020
e6c8469
console error if --enable-small
srubin Dec 4, 2020
024d45e
try to include ffmpeg/ffprobe from ffmpeg-ffprobe-static for linux/wi…
srubin Dec 4, 2020
1966a97
try regex again
srubin Dec 4, 2020
57c28a1
windows escaping
srubin Dec 4, 2020
a9730fb
bash??
srubin Dec 4, 2020
a8780a9
rc4 -- should have a better way to update that
srubin Dec 4, 2020
9dcdfd6
Update package.json
srubin Dec 4, 2020
6c32789
cleanup
srubin Dec 5, 2020
45928fa
Update paths.js
srubin Dec 5, 2020
83a810e
Update paths.d.ts
srubin Dec 5, 2020
ecc932b
Update package.json
srubin Dec 5, 2020
c66b55d
Update .github/workflows/prebuild.yml
srubin Dec 5, 2020
b350bdc
Update .github/workflows/prebuild.yml
srubin Dec 7, 2020
56de885
PR feedback
srubin Dec 7, 2020
7d39a64
Create .node-version
srubin Dec 7, 2020
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
27 changes: 18 additions & 9 deletions .github/workflows/prebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,43 @@ jobs:
with:
node-version: 14.8.0

- name: npm install
run: npm install
env:
PREBUILD: true

- name: install Linux dependencies
run: |
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo apt-get update
sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev libavfilter-dev libavutil-dev libpostproc-dev libswresample-dev libswscale-dev
if: ${{ runner.os == 'Linux' }}

- name: install Mac dependencies
run: brew install nasm pkg-config ffmpeg
- name: install Mac build dependencies (brew)
run: brew install nasm pkg-config
if: ${{ runner.os == 'macOS'}}

- name: install Mac dependencies (shared release)
run: node ./install_ffmpeg.js
if: ${{ runner.os == 'macOS'}}

- name: install Windows dependencies
run: node ./install_ffmpeg.js
if: ${{ runner.os == 'Windows'}}

- name: prebuild for macOS (x64)
run: npx prebuild --runtime napi --arch x64 --prepack copy_mac_libs.js --include-regex '\.(node|dylib)$' --upload ${{ secrets.GITHUB_TOKEN }}
run: npx prebuild --runtime napi --arch x64 --include-regex '(\.node|\.dylib|ffmpeg|ffprobe)$' --upload ${{ secrets.GITHUB_TOKEN }}
if: ${{ runner.os == 'macOS'}}

- name: prebuild for macOS (arm64)
run: npx prebuild --runtime napi --arch arm64 --prepack copy_mac_libs.js --include-regex '\.(node|dylib)$' --upload ${{ secrets.GITHUB_TOKEN }}
if: ${{ runner.os == 'macOS'}}
# - name: prebuild for macOS (arm64)
# run: npx prebuild --runtime napi --arch arm64 --include-regex '(\.node|\.dylib|ffmpeg|ffprobe)$' --upload ${{ secrets.GITHUB_TOKEN }}
# if: ${{ runner.os == 'macOS'}}

- name: prebuild for Windows
# I can't get the pipe character to work on windows, so to include both .node and .dll files I have this weird regexp
run: npx prebuild --runtime napi --include-regex '\.[nd][ol][dl]e?$' --upload ${{ secrets.GITHUB_TOKEN }}
run: npx prebuild --runtime napi --include-regex '"(\.node|\.dll|ffmpeg\.exe|ffprobe\.exe)$"' --upload ${{ secrets.GITHUB_TOKEN }}
shell: bash
if: ${{ runner.os == 'Windows'}}

- name: prebuild for Linux
run: npx prebuild --runtime napi --upload ${{ secrets.GITHUB_TOKEN }}
run: npx prebuild --runtime napi --include-regex '(\.node|\.dylib|ffmpeg|ffprobe)$' --upload ${{ secrets.GITHUB_TOKEN }}
if: ${{ runner.os == 'Linux'}}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ ffmpeg/
# Editors and IDE's
*.swp
.vscode/

.DS_Store
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12.18.3
62 changes: 60 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"NAPI_VERSION=<(napi_build_version)"
],
"conditions": [
['OS!="win"', {
['OS=="linux"', {
"defines": [
"__STDC_CONSTANT_MACROS"
],
Expand All @@ -35,8 +35,64 @@
"-lswresample",
"-lswscale"
]
}
},
"copies": [
{
"destination": "build/Release/",
"files": [
"node_modules/ffmpeg-ffprobe-static/ffmpeg",
"node_modules/ffmpeg-ffprobe-static/ffprobe",
]
}
]
}],
["OS=='mac'", {
"variables": {
"ffmpeg_version": "1.21.rc5"
},
"defines": [
"__STDC_CONSTANT_MACROS"
],
"cflags_cc!": [
"-fno-rtti",
"-fno-exceptions"
],
"cflags_cc": [
"-std=c++11",
"-fexceptions"
],
"include_dirs": [
"<(module_root_dir)/ffmpeg/ffmpeg-ffprobe-shared-darwin-x86_64.<(ffmpeg_version)/include/"
],
"link_settings": {
"library_dirs": [
"<(module_root_dir)/ffmpeg/ffmpeg-ffprobe-shared-darwin-x86_64.<(ffmpeg_version)/"
],
"libraries": [
"-Wl,-rpath,@loader_path",
"-lavcodec",
"-lavdevice",
"-lavfilter",
"-lavformat",
"-lavutil",
"-lpostproc",
"-lswresample",
"-lswscale"
],
},
'xcode_settings': {
'MACOSX_DEPLOYMENT_TARGET': '10.11',
},
"copies": [
{
"destination": "build/Release/",
"files": [
"<!@(node -p \"require('fs').readdirSync('ffmpeg/ffmpeg-ffprobe-shared-darwin-x86_64.<(ffmpeg_version)').map(f => 'ffmpeg/ffmpeg-ffprobe-shared-darwin-x86_64.<(ffmpeg_version)/' + f).join(' ')\")"
]
}
]
}
],
['OS=="win"', {
"configurations": {
"Release": {
Expand Down Expand Up @@ -72,6 +128,8 @@
"ffmpeg/ffmpeg-4.3-win64-shared/bin/postproc-55.dll",
"ffmpeg/ffmpeg-4.3-win64-shared/bin/swresample-3.dll",
"ffmpeg/ffmpeg-4.3-win64-shared/bin/swscale-5.dll"
"node_modules/ffmpeg-ffprobe-static/ffmpeg.exe",
"node_modules/ffmpeg-ffprobe-static/ffprobe.exe",
]
}
]
Expand Down
50 changes: 0 additions & 50 deletions copy_mac_libs.js

This file was deleted.

1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from "./types/Encoder"
export * from "./types/Muxer"
export * from "./types/Beamstreams"
export * from "./types/HWContext"
export * from "./types/paths"

export const AV_NOPTS_VALUE: number

Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ https://github.com/Streampunk/beamcoder/blob/master/LICENSE`;
console.log(splash);
console.log('Using FFmpeg version', beamcoder.avVersionInfo());

if (Object.values(beamcoder.configurations()).some(value => value.includes('--enable-small'))) {
console.error('beamcoder will crash because ffmpeg is compiled' +
' with --enable-small (because, for example, codec->long_name is ' +
'NULL and beamcoder expects it to be defined)');
}

beamcoder.demuxerStream = beamstreams.demuxerStream;
beamcoder.muxerStream = beamstreams.muxerStream;

Expand Down
5 changes: 5 additions & 0 deletions install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const {execSync} = require('child_process');

if (!process.env.PREBUILD) {
execSync('npx prebuild-install --runtime napi');
}
53 changes: 26 additions & 27 deletions install_ffmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,35 +175,34 @@ sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev libavfilter-
}

async function darwin() {
console.log('Checking for FFmpeg dependencies via HomeBrew.');
let output;
let returnMessage;

try {
output = await exec('brew list ffmpeg');
returnMessage = 'FFmpeg already present via Homebrew.';
} catch (err) {
if (err.stderr !== 'Error: No such keg: /usr/local/Cellar/ffmpeg\n') {
console.error(err);
console.log('Either Homebrew is not installed or something else is wrong.\nExiting');
process.exit(1);
}

console.log('FFmpeg not installed. Attempting to install via Homebrew.');
try {
output = await exec('brew install nasm pkg-config texi2html ffmpeg');
returnMessage = 'FFmpeg installed via Homebrew.';
} catch (err) {
console.log('Failed to install ffmpeg:\n');
console.error(err);
process.exit(1);
}
}
console.log('Checking/downloading ffmpeg shared libraries');

await mkdir('ffmpeg').catch(e => {
if (e.code === 'EEXIST') return;
else throw e;
});

const version = '1.21.rc5';
const ffmpegFilename = `ffmpeg-ffprobe-shared-darwin-x86_64.${version}`;

console.log(output.stdout);
console.log(returnMessage);
await access(`ffmpeg/${ffmpegFilename}`, fs.constants.R_OK).catch(async () => {
const ws = fs.createWriteStream(`ffmpeg/${ffmpegFilename}.zip`);
await get(
ws,
`https://github.com/descriptinc/ffmpeg-build-script/releases/download/v${version}/${ffmpegFilename}.zip`,
`${ffmpegFilename}.zip`
).catch(async (err) => {
if (err.name === 'RedirectError') {
const redirectURL = err.message;
await get(ws, redirectURL, `${ffmpegFilename}.zip`);
} else {
console.error(err);
throw err;
}
});

return 0;
await exec(`unzip ffmpeg/${ffmpegFilename}.zip -d ffmpeg/${ffmpegFilename}/`);
});
}

switch (os.platform()) {
Expand Down
Loading