Skip to content

Commit 39f0308

Browse files
feat: ffmpeg v7 (#1777)
* adding ffmpeg v7 * Renaming id ffmpeg to ffmpeg7 * added space * fixing formatting issue * fix unit test workflow for forks * merge ffmpeg v7 into existing extension * verify md5 checksum * fix dns resolution * fix v7 install * remove redundant code * add changeset * mark fluent-ffmpeg as external * add docs * Revert "mark fluent-ffmpeg as external" This reverts commit 74cd317. --------- Co-authored-by: nicktrn <[email protected]>
1 parent 21c0dc6 commit 39f0308

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

.changeset/thick-bikes-laugh.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/build": patch
3+
---
4+
5+
Add ffmpeg v7 support to existing extension: `ffmpeg({ version: "7" })`

docs/config/extensions/ffmpeg.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ export default defineConfig({
1919
});
2020
```
2121

22-
By default, this will install the version of `ffmpeg` that is available in the Debian package manager. If you need a specific version, you can pass in the version as an argument:
22+
By default, this will install the version of `ffmpeg` that is available in the Debian package manager (via `apt`).
23+
24+
## FFmpeg 7.x (static build)
25+
26+
If you need FFmpeg 7.x, you can pass `{ version: "7" }` to the extension. This will install a static build of FFmpeg 7.x instead of using the Debian package:
2327

2428
```ts
2529
import { defineConfig } from "@trigger.dev/sdk/v3";
@@ -29,7 +33,7 @@ export default defineConfig({
2933
project: "<project ref>",
3034
// Your other config settings...
3135
build: {
32-
extensions: [ffmpeg({ version: "6.0-4" })],
36+
extensions: [ffmpeg({ version: "7" })],
3337
},
3438
});
3539
```

packages/build/src/extensions/core/ffmpeg.ts

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
import { BuildExtension } from "@trigger.dev/core/v3/build";
22

33
export type FfmpegOptions = {
4+
/**
5+
* The version of ffmpeg to install. If not provided, the latest version from apt will be installed.
6+
* If set to '7' or starts with '7.', a static build of ffmpeg 7.x from johnvansickle.com will be used instead of apt.
7+
* @example
8+
* ffmpeg() // Installs latest ffmpeg from apt
9+
* ffmpeg({ version: '7' }) // Installs static build of ffmpeg 7.x
10+
* ffmpeg({ version: '7.0.1' }) // Installs static build of ffmpeg 7.x
11+
* ffmpeg({ version: '6' }) // Version ignored, installs latest ffmpeg from apt
12+
* ffmpeg({ version: '8' }) // Version ignored, installs latest ffmpeg from apt
13+
*/
414
version?: string;
515
};
616

717
/**
818
* Add ffmpeg to the build, and automatically set the FFMPEG_PATH and FFPROBE_PATH environment variables.
9-
* @param options.version The version of ffmpeg to install. If not provided, the latest version will be installed.
19+
* @param options.version The version of ffmpeg to install. If not provided, the latest version from apt will be installed.
20+
* If set to '7' or starts with '7.', a static build of ffmpeg 7.x from johnvansickle.com will be used instead of apt.
1021
*
1122
* @returns The build extension.
1223
*/
@@ -22,10 +33,41 @@ export function ffmpeg(options: FfmpegOptions = {}): BuildExtension {
2233
options,
2334
});
2435

36+
// Use static build for version 7 or 7.x
37+
if (options.version === "7" || options.version?.startsWith("7.")) {
38+
context.addLayer({
39+
id: "ffmpeg",
40+
image: {
41+
instructions: [
42+
// Install ffmpeg after checksum validation
43+
"RUN apt-get update && apt-get install -y --no-install-recommends wget xz-utils nscd ca-certificates && apt-get clean && rm -rf /var/lib/apt/lists/* && " +
44+
"wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz.md5 && " +
45+
"wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz && " +
46+
"md5sum -c ffmpeg-git-amd64-static.tar.xz.md5 && " +
47+
"tar xvf ffmpeg-git-amd64-static.tar.xz -C /usr/bin --strip-components=1 --no-anchored 'ffmpeg' 'ffprobe' && " +
48+
"rm ffmpeg-git-amd64-static.tar.xz*",
49+
],
50+
},
51+
deploy: {
52+
env: {
53+
FFMPEG_PATH: "/usr/bin/ffmpeg",
54+
FFPROBE_PATH: "/usr/bin/ffprobe",
55+
},
56+
override: true,
57+
},
58+
});
59+
return;
60+
} else if (options.version) {
61+
context.logger.warn("Custom ffmpeg version not supported, ignoring", {
62+
version: options.version,
63+
});
64+
}
65+
66+
// Default: use apt
2567
context.addLayer({
2668
id: "ffmpeg",
2769
image: {
28-
pkgs: options.version ? [`ffmpeg=${options.version}`] : ["ffmpeg"],
70+
pkgs: ["ffmpeg"],
2971
},
3072
deploy: {
3173
env: {

0 commit comments

Comments
 (0)