Skip to content

Commit 593d712

Browse files
committed
Use page with stable link names to handle autobuild updates
1 parent 216cfe5 commit 593d712

File tree

3 files changed

+52
-20
lines changed

3 files changed

+52
-20
lines changed

binding.gyp

+17-17
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,30 @@
4545
}
4646
},
4747
"include_dirs" : [
48-
"ffmpeg/ffmpeg-4.3.1-win64-shared/include"
48+
"ffmpeg/ffmpeg-4.3-win64-shared/include"
4949
],
5050
"libraries": [
51-
"-l../ffmpeg/ffmpeg-4.3.1-win64-shared/lib/avcodec",
52-
"-l../ffmpeg/ffmpeg-4.3.1-win64-shared/lib/avdevice",
53-
"-l../ffmpeg/ffmpeg-4.3.1-win64-shared/lib/avfilter",
54-
"-l../ffmpeg/ffmpeg-4.3.1-win64-shared/lib/avformat",
55-
"-l../ffmpeg/ffmpeg-4.3.1-win64-shared/lib/avutil",
56-
"-l../ffmpeg/ffmpeg-4.3.1-win64-shared/lib/postproc",
57-
"-l../ffmpeg/ffmpeg-4.3.1-win64-shared/lib/swresample",
58-
"-l../ffmpeg/ffmpeg-4.3.1-win64-shared/lib/swscale"
51+
"-l../ffmpeg/ffmpeg-4.3-win64-shared/lib/avcodec",
52+
"-l../ffmpeg/ffmpeg-4.3-win64-shared/lib/avdevice",
53+
"-l../ffmpeg/ffmpeg-4.3-win64-shared/lib/avfilter",
54+
"-l../ffmpeg/ffmpeg-4.3-win64-shared/lib/avformat",
55+
"-l../ffmpeg/ffmpeg-4.3-win64-shared/lib/avutil",
56+
"-l../ffmpeg/ffmpeg-4.3-win64-shared/lib/postproc",
57+
"-l../ffmpeg/ffmpeg-4.3-win64-shared/lib/swresample",
58+
"-l../ffmpeg/ffmpeg-4.3-win64-shared/lib/swscale"
5959
],
6060
"copies": [
6161
{
6262
"destination": "build/Release/",
6363
"files": [
64-
"ffmpeg/ffmpeg-4.3.1-win64-shared/bin/avcodec-58.dll",
65-
"ffmpeg/ffmpeg-4.3.1-win64-shared/bin/avdevice-58.dll",
66-
"ffmpeg/ffmpeg-4.3.1-win64-shared/bin/avfilter-7.dll",
67-
"ffmpeg/ffmpeg-4.3.1-win64-shared/bin/avformat-58.dll",
68-
"ffmpeg/ffmpeg-4.3.1-win64-shared/bin/avutil-56.dll",
69-
"ffmpeg/ffmpeg-4.3.1-win64-shared/bin/postproc-55.dll",
70-
"ffmpeg/ffmpeg-4.3.1-win64-shared/bin/swresample-3.dll",
71-
"ffmpeg/ffmpeg-4.3.1-win64-shared/bin/swscale-5.dll"
64+
"ffmpeg/ffmpeg-4.3-win64-shared/bin/avcodec-58.dll",
65+
"ffmpeg/ffmpeg-4.3-win64-shared/bin/avdevice-58.dll",
66+
"ffmpeg/ffmpeg-4.3-win64-shared/bin/avfilter-7.dll",
67+
"ffmpeg/ffmpeg-4.3-win64-shared/bin/avformat-58.dll",
68+
"ffmpeg/ffmpeg-4.3-win64-shared/bin/avutil-56.dll",
69+
"ffmpeg/ffmpeg-4.3-win64-shared/bin/postproc-55.dll",
70+
"ffmpeg/ffmpeg-4.3-win64-shared/bin/swresample-3.dll",
71+
"ffmpeg/ffmpeg-4.3-win64-shared/bin/swscale-5.dll"
7272
]
7373
}
7474
]

install_ffmpeg.js

+34-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ async function get(ws, url, name) {
5353
});
5454
}
5555

56+
async function getHTML(url, name) {
57+
let received = 0;
58+
let totalLength = 0;
59+
return new Promise((resolve, reject) => {
60+
https.get(url, res => {
61+
const chunks = [];
62+
if (totalLength == 0) {
63+
totalLength = +res.headers['content-length'];
64+
}
65+
res.on('end', () => {
66+
process.stdout.write(`Downloaded 100% of '${name}'. Total length ${received} bytes.\n`);
67+
resolve(Buffer.concat(chunks));
68+
});
69+
res.on('error', reject);
70+
res.on('data', (chunk) => {
71+
chunks.push(chunk);
72+
received += chunk.length;
73+
process.stdout.write(`Downloaded ${received * 100/ totalLength | 0 }% of '${name}'.\r`);
74+
});
75+
}).on('error', reject);
76+
});
77+
}
78+
5679
async function inflate(rs, folder, name) {
5780
const unzip = require('unzipper');
5881
const directory = await unzip.Open.file(`${folder}/${name}.zip`);
@@ -77,9 +100,18 @@ async function win32() {
77100
else throw e;
78101
});
79102

80-
const ffmpegFilename = 'ffmpeg-4.3.1-win64-shared';
81-
const downloadSource = 'https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2020-09-30-13-11/ffmpeg-n4.3.1-19-gaf2a430bb1-win64-gpl-shared-4.3.zip';
103+
const ffmpegFilename = 'ffmpeg-4.3-win64-shared';
82104
await access(`ffmpeg/${ffmpegFilename}`, fs.constants.R_OK).catch(async () => {
105+
const html = await getHTML('https://github.com/BtbN/FFmpeg-Builds/wiki/Latest', 'latest autobuilds');
106+
const htmlStr = html.toString('utf-8');
107+
const autoPos = htmlStr.indexOf('<p><a href=');
108+
const endPos = htmlStr.indexOf('</div>', autoPos);
109+
const autoStr = htmlStr.substring(autoPos, endPos);
110+
const sharedEndPos = autoStr.lastIndexOf('">win64-gpl-shared-4.3');
111+
const startStr = '<p><a href="';
112+
const sharedStartPos = autoStr.lastIndexOf(startStr, sharedEndPos) + startStr.length;
113+
const downloadSource = autoStr.substring(sharedStartPos, sharedEndPos);
114+
83115
let ws_shared = fs.createWriteStream(`ffmpeg/${ffmpegFilename}.zip`);
84116
await get(ws_shared, downloadSource, `${ffmpegFilename}.zip`)
85117
.catch(async (err) => {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "beamcoder",
3-
"version": "0.6.2",
3+
"version": "0.6.3",
44
"description": "Node.js native bindings to FFmpeg.",
55
"main": "index.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)