Skip to content

Commit 0ec8a28

Browse files
author
Srikanth Kotagiri
committed
Updating pre-install script
1 parent 75bb34a commit 0ec8a28

File tree

3 files changed

+61
-19
lines changed

3 files changed

+61
-19
lines changed

.github/workflows/prebuild.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,10 @@ on: [push]
33

44
jobs:
55
linux-package:
6-
runs-on: ubuntu-latest
6+
runs-on: ubuntu-24.04
77
container:
88
image: node:16.20.2-bookworm
99
steps:
10-
- name: install Linux dependencies
11-
run: |
12-
apt-get update
13-
apt-get install -y build-essential git git-lfs pkg-config libtool python3 python-is-python3
14-
apt-get install -y libavcodec-dev libavformat-dev libavdevice-dev libavfilter-dev libavutil-dev libpostproc-dev libswresample-dev libswscale-dev libzimg-dev
15-
1610
- uses: actions/checkout@v2
1711
with:
1812
lfs: true

binding.gyp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"src/codec.cc", "src/hwcontext.cc" ],
1515
"conditions": [
1616
['OS=="linux"', {
17+
"variables": {
18+
"ffmpeg_version": "1.49.rc.1",
19+
"target_arch_override": "<!(node -p \"'<(target_arch)' === 'x64' ? 'x86_64' : '<(target_arch)'\")",
20+
},
1721
"defines": [
1822
"__STDC_CONSTANT_MACROS"
1923
],
@@ -25,7 +29,14 @@
2529
"-std=c++11",
2630
"-fexceptions"
2731
],
32+
"include_dirs": [
33+
"<(module_root_dir)/ffmpeg/ffmpeg-ffprobe-shared-linux-<(target_arch_override).<(ffmpeg_version)/include/"
34+
],
35+
2836
"link_settings": {
37+
"library_dirs": [
38+
"<(module_root_dir)/ffmpeg/ffmpeg-ffprobe-shared-linux-<(target_arch_override).<(ffmpeg_version)/"
39+
],
2940
"libraries": [
3041
"-lavcodec",
3142
"-lavdevice",
@@ -139,18 +150,6 @@
139150
}
140151
]
141152
}],
142-
['OS=="linux"', {
143-
"libraries": [
144-
"<!(pkg-config --libs libavcodec)",
145-
"<!(pkg-config --libs libavdevice)",
146-
"<!(pkg-config --libs libavfilter)",
147-
"<!(pkg-config --libs libavformat)",
148-
"<!(pkg-config --libs libavutil)",
149-
"<!(pkg-config --libs libpostproc)",
150-
"<!(pkg-config --libs libswresample)",
151-
"<!(pkg-config --libs libswscale)"
152-
]
153-
}],
154153
['OS=="mac"', {
155154
"include_dirs" : [
156155
"/opt/homebrew/Cellar/ffmpeg/5.0/include"

install_ffmpeg.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,55 @@ async function win32() {
131131
}
132132

133133
async function linux() {
134+
console.log('Checking/downloading ffmpeg shared libraries');
135+
136+
await mkdir('ffmpeg').catch(e => {
137+
if (e.code === 'EEXIST') return;
138+
else throw e;
139+
});
140+
141+
const version = '1.49.rc.1';
142+
143+
// default to platform-architecture
144+
let arch = os.arch();
145+
146+
// but if the '--arch' argument is provided
147+
// use the next argument as the value (e.g. 'x64' or 'arm64')
148+
const overrideArchIndex = process.argv.indexOf('--arch');
149+
if (0 < overrideArchIndex && overrideArchIndex < process.argv.length - 1) {
150+
arch = process.argv[overrideArchIndex + 1];
151+
}
152+
153+
if (arch === 'x64') {
154+
arch = 'x86_64';
155+
}
156+
157+
const ffmpegFilename = `ffmpeg-ffprobe-shared-linux-${arch}.${version}`;
158+
const tag = `v${version}`;
159+
160+
await access(`ffmpeg/${ffmpegFilename}`, fs.constants.R_OK).catch(async () => {
161+
const ws = fs.createWriteStream(`ffmpeg/${ffmpegFilename}.zip`);
162+
const url = `https://github.com/descriptinc/ffmpeg-build-script/releases/download/${tag}/${ffmpegFilename}.zip`
163+
console.log(url);
164+
await get(
165+
ws,
166+
url,
167+
`${ffmpegFilename}.zip`
168+
).catch(async (err) => {
169+
if (err.name === 'RedirectError') {
170+
const redirectURL = err.message;
171+
await get(ws, redirectURL, `${ffmpegFilename}.zip`);
172+
} else {
173+
console.error(err);
174+
throw err;
175+
}
176+
});
177+
178+
await exec(`unzip ffmpeg/${ffmpegFilename}.zip -d ffmpeg/${ffmpegFilename}/`);
179+
await exec(`echo "$PWD/ffmpeg/${ffmpegFilename}/" | tee -a /etc/ld.so.conf.d/ffmpeg.conf`)
180+
await exec(`ldconfig`)
181+
});
182+
134183
console.log('Checking FFmpeg dependencies for Beam Coder on Linux.');
135184
const { stdout } = await execFile('ldconfig', ['-p']).catch(console.error);
136185
let result = 0;

0 commit comments

Comments
 (0)