Skip to content

Commit bcd9b88

Browse files
authored
Clarify QSV support and housekeeping. (#93)
1 parent ad6f97d commit bcd9b88

File tree

5 files changed

+86
-91
lines changed

5 files changed

+86
-91
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ This project provides static FFmpeg binaries for multiple platforms and architec
1616
Specifically, we provide:
1717

1818
* Audio support using `libfdk-aac`.
19-
* Hardware-accelerated encoding support on Intel platforms using `h264_qsv` and hardware-accelerated encoding on Raspberry Pi 4+ using `h264_v4l2m2m`.
19+
* Hardware-accelerated encoding support on Intel platforms using `h264_qsv` **(Windows only)**.
20+
* Hardware-accelerated encoding support on Raspberry Pi 4+ using `h264_v4l2m2m`.
2021
* Hardware-accelerated encoding support on Apple platforms using `videotoolbox`.
2122

2223
## Supported Platforms
@@ -29,6 +30,7 @@ Specifically, we provide:
2930
| Windows 10 or newer | x86_64 |
3031

3132
> [!NOTE]
33+
> * **Intel Quick Sync Video is only supported on Windows. There are multiple known issues with `libva` that make it incompatible with static builds of FFmpeg. If you need QSV on Linux, we recommend looking at the [Jellyfin FFmpeg distribution](https://repo.jellyfin.org/?path=/ffmpeg) for distribution-specific releases. We hope to support QSV on Linux once these issues are addressed.**
3234
> * **Raspberry Pi 5 is currently unsupported. There are multiple known issues with FFmpeg and Raspberry Pi 5 that will hopefully be addressed by the respective teams in the future.**
3335
> * **Currently (October 2024), FFmpeg v7.1 appears to be somewhat broken for HEVC and H.264 decoding in some scenarios. We hope to support future FFmpeg LTS releases as they stabilize and mature.**
3436

build-ffmpeg

Lines changed: 33 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -801,12 +801,6 @@ if ${NONFREE_AND_GPL}; then
801801
CONFIGURE_OPTIONS+=("--enable-libx264")
802802
fi
803803

804-
#TARGET_OS = alpine
805-
#TARGET_ARCH = arm32v7
806-
#OSTYPE = linux-musleabihf
807-
#
808-
# if ${NONFREE_AND_GPL} && [[ ! "${TARGET_ARCH}" == "arm"* ]]; then
809-
#if ${NONFREE_AND_GPL}; then
810804
if ${NONFREE_AND_GPL} && (isAppleSilicon || [[ ! "${TARGET_ARCH}" == "arm"* ]]) ; then
811805

812806
if build "x265" "latest"; then
@@ -818,16 +812,6 @@ if ${NONFREE_AND_GPL} && (isAppleSilicon || [[ ! "${TARGET_ARCH}" == "arm"* ]])
818812

819813
clone "https://bitbucket.org/multicoreware/x265_git.git" "x265-latest"
820814
fi
821-
# if [[ "${TARGET_OS}" == "darwin" && "${TARGET_ARCH}" == "arm64" ]]; then
822-
#
823-
# download "https://bitbucket.org/multicoreware/x265_git/get/931178347b3f73e40798fd5180209654536bbaa5.tar.gz" "x265-3.5.tar.gz" # This is actually 3.4 if looking at x265Versio
824-
# elif [[ "${TARGET_ARCH}" == "arm"* ]]; then
825-
#
826-
# download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz" # This is actually 3.4 if looking at x265Version.txt
827-
# else
828-
#
829-
# clone "https://bitbucket.org/multicoreware/x265_git.git" "x265-latest"
830-
# fi
831815

832816
cd build/linux || exit
833817
execute cmake -G "Unix Makefiles" ../../source
@@ -957,7 +941,6 @@ if ${NONFREE_AND_GPL}; then
957941
fi
958942

959943
if [[ ! "${TARGET_ARCH}" == "arm"* ]]; then
960-
#if [[ ! "${TARGET_OS}" == "raspbian" ]]; then
961944

962945
if build "av1" "bcfe6fb"; then
963946

@@ -1341,38 +1324,39 @@ fi
13411324

13421325
if isLinux && [[ "${TARGET_ARCH}" == "x86_64" ]]; then
13431326

1344-
# Intel QSV support.
1345-
if build "oneVPL" "v2023.3.1"; then
1346-
1347-
download "https://github.com/oneapi-src/oneVPL/archive/refs/tags/v2023.3.1.tar.gz" "oneVPL-v2023.3.1.tar.gz"
1348-
1349-
make_dir build
1350-
cd build || exit
1351-
1352-
execute cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_LIBDIR=lib \
1353-
-DBUILD_DISPATCHER=ON -DBUILD_DEV=ON -DBUILD_PREVIEW=OFF -DBUILD_TOOLS=OFF -DBUILD_TOOLS_ONEVPL_EXPERIMENTAL=OFF -DINSTALL_EXAMPLE_CODE=OFF \
1354-
-DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF ..
1355-
execute cmake --build . --config Release
1356-
execute cmake --build . --config Release --target install
1357-
1358-
build_done "oneVPL" "v2023.3.1"
1359-
fi
1360-
1361-
CONFIGURE_OPTIONS+=("--enable-libvpl")
1362-
1363-
# Libva support.
1364-
if build "libva" "latest"; then
1365-
1366-
download "https://github.com/intel/libva/archive/refs/tags/2.20.0.tar.gz" "libva-2.20.0.tar.gz"
1367-
1368-
execute env LIBTOOLIZE="${WORKSPACE}/bin/libtoolize" ./autogen.sh --prefix="${WORKSPACE}" --with-drivers-path="/usr/lib/x86_64-linux-gnu/dri" --enable-static --disable-shared
1369-
execute make -j ${MJOBS}
1370-
execute make install
1371-
1372-
build_done "libva" "2.20.0"
1373-
fi
1374-
1375-
CONFIGURE_OPTIONS+=("--enable-vaapi")
1327+
# Unfortunately, libva is broken in static builds of FFmpeg, making QSV out of reach for the time being.
1328+
# # Intel QSV support.
1329+
# if build "oneVPL" "v2023.3.1"; then
1330+
#
1331+
# download "https://github.com/oneapi-src/oneVPL/archive/refs/tags/v2023.3.1.tar.gz" "oneVPL-v2023.3.1.tar.gz"
1332+
#
1333+
# make_dir build
1334+
# cd build || exit
1335+
#
1336+
# execute cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_LIBDIR=lib \
1337+
# -DBUILD_DISPATCHER=ON -DBUILD_DEV=ON -DBUILD_PREVIEW=OFF -DBUILD_TOOLS=OFF -DBUILD_TOOLS_ONEVPL_EXPERIMENTAL=OFF -DINSTALL_EXAMPLE_CODE=OFF \
1338+
# -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF ..
1339+
# execute cmake --build . --config Release
1340+
# execute cmake --build . --config Release --target install
1341+
#
1342+
# build_done "oneVPL" "v2023.3.1"
1343+
# fi
1344+
#
1345+
# CONFIGURE_OPTIONS+=("--enable-libvpl")
1346+
#
1347+
# # Libva support.
1348+
# if build "libva" "latest"; then
1349+
#
1350+
# download "https://github.com/intel/libva/archive/refs/tags/2.20.0.tar.gz" "libva-2.20.0.tar.gz"
1351+
#
1352+
# execute env LIBTOOLIZE="${WORKSPACE}/bin/libtoolize" ./autogen.sh --prefix="${WORKSPACE}" --with-drivers-path="/usr/lib/x86_64-linux-gnu/dri" --enable-static --disable-shared
1353+
# execute make -j ${MJOBS}
1354+
# execute make install
1355+
#
1356+
# build_done "libva" "2.20.0"
1357+
# fi
1358+
#
1359+
# CONFIGURE_OPTIONS+=("--enable-vaapi")
13761360

13771361
if command_exists "nvcc"; then
13781362

install.js

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ function makeFfmpegCacheDir() {
2626

2727
function ensureFfmpegCacheDir() {
2828

29-
if (!fs.existsSync(ffmpegCache())) {
29+
if(!fs.existsSync(ffmpegCache())) {
3030

3131
return makeFfmpegCacheDir();
3232
}
3333
}
3434

3535
async function getDownloadFileName() {
3636

37-
switch (os.platform()) {
37+
switch(os.platform()) {
3838

3939
case "darwin":
4040

41-
if (parseInt(os.release()) >= 22) {
41+
if(parseInt(os.release()) >= 22) {
4242

43-
switch (process.arch) {
43+
switch(process.arch) {
4444

4545
case "x64":
4646

@@ -59,16 +59,25 @@ async function getDownloadFileName() {
5959

6060
let osReleaseEnv = {};
6161

62-
if (fs.existsSync("/etc/os-release")) {
62+
if(fs.existsSync("/etc/os-release")) {
6363

6464
osReleaseEnv = dotenv.parse(fs.readFileSync("/etc/os-release"));
6565
}
6666

67-
switch (process.arch) {
67+
switch(process.arch) {
6868

69-
case "x64":
69+
case "x64":
70+
71+
switch(osReleaseEnv.VERSION_ID) {
72+
73+
case "24.04":
74+
75+
return "ffmpeg-ubuntu-24.04-x86_64.tar.gz";
76+
77+
default:
7078

71-
return "ffmpeg-alpine-x86_64.tar.gz";
79+
return "ffmpeg-alpine-x86_64.tar.gz";
80+
}
7281

7382
case "arm":
7483

@@ -85,7 +94,7 @@ async function getDownloadFileName() {
8594

8695
case "freebsd":
8796

88-
switch (process.arch) {
97+
switch(process.arch) {
8998

9099
case "x64":
91100

@@ -98,10 +107,10 @@ async function getDownloadFileName() {
98107

99108
case "win32":
100109

101-
if (process.arch === "x64") {
110+
if(process.arch === "x64") {
102111

103112
return "ffmpeg.exe"
104-
}
113+
}
105114

106115
return null;
107116

@@ -113,7 +122,7 @@ async function getDownloadFileName() {
113122

114123
async function downloadFfmpeg(downloadUrl, ffmpegDownloadPath) {
115124

116-
// open write stream to download location
125+
// Open a write stream to the download location.
117126
const tempFile = path.resolve(ffmpegCache(), ".download");
118127
const file = fs.createWriteStream(tempFile);
119128

@@ -125,7 +134,7 @@ async function downloadFfmpeg(downloadUrl, ffmpegDownloadPath) {
125134
url: downloadUrl,
126135
}, (err, res) => {
127136

128-
if (err || res.statusCode !== 200) {
137+
if(err || res.statusCode !== 200) {
129138

130139
return reject(err);
131140
}
@@ -139,7 +148,7 @@ async function downloadFfmpeg(downloadUrl, ffmpegDownloadPath) {
139148
const percent = Math.round((downloadedBytes / totalBytes) * 100) + "%";
140149
process.stdout.write("\r" + percent);
141150
});
142-
151+
143152
file.on("finish", () => {
144153

145154
console.log(" - Download Complete");
@@ -183,17 +192,17 @@ function displayErrorMessage() {
183192
// Attempt to install a working version of FFmpeg for the system we are running on.
184193
async function install() {
185194

186-
// ensure the ffmpeg npm cache directory exists
195+
// Ensure the FFmpeg npm cache directory exists.
187196
ensureFfmpegCacheDir();
188197

189-
// work out the download file name for the current platform
198+
// Determine the download file name for the current platform.
190199
const ffmpegDownloadFileName = await getDownloadFileName();
191200

192-
if (!ffmpegDownloadFileName) {
201+
if(!ffmpegDownloadFileName) {
193202

194-
if (os.platform() === "darwin" && parseInt(os.release()) < 22) {
203+
if(os.platform() === "darwin" && parseInt(os.release()) < 24) {
195204

196-
console.log("ffmpeg-for-homebridge: macOS versions older than 13 (Ventura) are not supported, you will need to install a working version of FFmpeg manually.");
205+
console.log("ffmpeg-for-homebridge: macOS versions older than 15 (Sequoia) are not supported, you will need to install a working version of FFmpeg manually.");
197206
} else {
198207

199208
console.log("ffmpeg-for-homebridge: %s %s is not supported, you will need to install a working version of FFmpeg manually.", os.platform, process.arch);
@@ -202,62 +211,62 @@ async function install() {
202211
process.exit(0);
203212
}
204213

205-
// the file path where the download should go
214+
// The file path where the download will be located.
206215
const ffmpegDownloadPath = path.resolve(ffmpegCache(), targetFfmpegRelease() + "-" + ffmpegDownloadFileName);
207216

208-
// construct the download url
217+
// Construct the download url.
209218
const downloadUrl = "https://github.com/homebridge/ffmpeg-for-homebridge/releases/download/" + targetFfmpegRelease() + "/" + ffmpegDownloadFileName;
210219

211-
// download if not cached
212-
if (!fs.existsSync(ffmpegDownloadPath)) {
220+
// Download the latest release if it's not been previously cached.
221+
if(!fs.existsSync(ffmpegDownloadPath)) {
213222

214223
await downloadFfmpeg(downloadUrl, ffmpegDownloadPath);
215224
}
216225

217-
// contruct the path of the temporary ffmpeg binary
226+
// Contruct the path of the temporary FFmpeg binary.
218227
const ffmpegTempPath = path.resolve(ffmpegCache(), os.platform() === "win32" ? "ffmpeg.exe" : "ffmpeg");
219228
const ffmpegTargetPath = path.resolve(__dirname, os.platform() === "win32" ? "ffmpeg.exe" : "ffmpeg");
220229

221-
// extract ffmpeg binary from the downloaded tar.gz on non-windows platforms
222-
if (os.platform() !== "win32") {
230+
// Extract the FFmpeg binary from the downloaded tar.gz bundle on non-windows platforms.
231+
if(os.platform() !== "win32") {
223232

224233
try {
225234

226235
await tar.x({
227236

228237
file: ffmpegDownloadPath,
229238
C: ffmpegCache(),
230-
strip: 4, // tar.gz packs ffmpeg into /usr/local/bin - this strips that out
239+
strip: 4, // tar.gz packs ffmpeg into /usr/local/bin - this strips that out.
231240
});
232241
} catch (e) {
233242

234243
console.error(e);
235-
console.error("An error occured while extracting the downloaded ffmpeg binary.");
244+
console.error("An error occured while extracting the downloaded FFmpeg binary.");
236245
displayErrorMessage();
237-
238-
// delete the cached download if it failed to extract
246+
247+
// Delete the cached download if it failed to extract for some reason.
239248
fs.unlinkSync(ffmpegDownloadPath);
240249

241250
process.exit(0);
242251
}
243252

244-
if (fs.existsSync(ffmpegTempPath)) {
253+
// Set the execute permissions for FFmpeg.
254+
if(fs.existsSync(ffmpegTempPath)) {
245255

246256
fs.chmodSync(ffmpegTempPath, 0o755);
247257
}
248-
}
258+
} else {
249259

250-
// no need to extract for windows - just copy the downloaded binary to the temp path on windows
251-
if (os.platform() === "win32") {
260+
// There's no need to extract for Windows - we just copy the downloaded binary to the temp path.
252261

253262
fs.renameSync(ffmpegDownloadPath, ffmpegTempPath)
254263
}
255264

256265
// check if the downloaded binary works
257-
if (!binaryOk(ffmpegTempPath)) {
266+
if(!binaryOk(ffmpegTempPath)) {
258267

259268
displayErrorMessage();
260-
269+
261270
// delete the cached download if it failed the test
262271
fs.unlinkSync(ffmpegDownloadPath);
263272

@@ -273,14 +282,14 @@ async function install() {
273282
// Bootstrap the installation process.
274283
async function bootstrap() {
275284

276-
console.log("Building for version: %s", targetFfmpegRelease());
285+
console.log("Building for version: %s.", targetFfmpegRelease());
277286

278287
try {
279288

280289
await install();
281290
} catch (e) {
282291

283-
if (e && e.code && e.code === "EACCES") {
292+
if(e && e.code && e.code === "EACCES") {
284293

285294
console.log("Unable to download FFmpeg.\nIf you are installing this plugin as a global module (-g) make sure you add the --unsafe-perm flag to the install command.");
286295
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ffmpeg-for-homebridge",
3-
"version": "2.1.4",
3+
"version": "2.1.5",
44
"description": "Static FFmpeg binaries for Homebridge with support for audio (libfdk-aac) and hardware encoding (h264_v4l2m2m and h264_qsv).",
55
"author": {
66
"name": "The Homebridge Team",

0 commit comments

Comments
 (0)