diff --git a/.changeset/thick-bikes-laugh.md b/.changeset/thick-bikes-laugh.md new file mode 100644 index 0000000000..7166bfca64 --- /dev/null +++ b/.changeset/thick-bikes-laugh.md @@ -0,0 +1,5 @@ +--- +"@trigger.dev/build": patch +--- + +Add ffmpeg v7 support to existing extension: `ffmpeg({ version: "7" })` diff --git a/docs/config/extensions/ffmpeg.mdx b/docs/config/extensions/ffmpeg.mdx index 390e2796f0..581970b411 100644 --- a/docs/config/extensions/ffmpeg.mdx +++ b/docs/config/extensions/ffmpeg.mdx @@ -19,7 +19,11 @@ export default defineConfig({ }); ``` -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: +By default, this will install the version of `ffmpeg` that is available in the Debian package manager (via `apt`). + +## FFmpeg 7.x (static build) + +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: ```ts import { defineConfig } from "@trigger.dev/sdk/v3"; @@ -29,7 +33,7 @@ export default defineConfig({ project: "", // Your other config settings... build: { - extensions: [ffmpeg({ version: "6.0-4" })], + extensions: [ffmpeg({ version: "7" })], }, }); ``` diff --git a/packages/build/src/extensions/core/ffmpeg.ts b/packages/build/src/extensions/core/ffmpeg.ts index 84a91d7061..11e8c0c80a 100644 --- a/packages/build/src/extensions/core/ffmpeg.ts +++ b/packages/build/src/extensions/core/ffmpeg.ts @@ -1,12 +1,23 @@ import { BuildExtension } from "@trigger.dev/core/v3/build"; export type FfmpegOptions = { + /** + * The version of ffmpeg to install. If not provided, the latest version from apt will be installed. + * If set to '7' or starts with '7.', a static build of ffmpeg 7.x from johnvansickle.com will be used instead of apt. + * @example + * ffmpeg() // Installs latest ffmpeg from apt + * ffmpeg({ version: '7' }) // Installs static build of ffmpeg 7.x + * ffmpeg({ version: '7.0.1' }) // Installs static build of ffmpeg 7.x + * ffmpeg({ version: '6' }) // Version ignored, installs latest ffmpeg from apt + * ffmpeg({ version: '8' }) // Version ignored, installs latest ffmpeg from apt + */ version?: string; }; /** * Add ffmpeg to the build, and automatically set the FFMPEG_PATH and FFPROBE_PATH environment variables. - * @param options.version The version of ffmpeg to install. If not provided, the latest version will be installed. + * @param options.version The version of ffmpeg to install. If not provided, the latest version from apt will be installed. + * If set to '7' or starts with '7.', a static build of ffmpeg 7.x from johnvansickle.com will be used instead of apt. * * @returns The build extension. */ @@ -22,10 +33,41 @@ export function ffmpeg(options: FfmpegOptions = {}): BuildExtension { options, }); + // Use static build for version 7 or 7.x + if (options.version === "7" || options.version?.startsWith("7.")) { + context.addLayer({ + id: "ffmpeg", + image: { + instructions: [ + // Install ffmpeg after checksum validation + "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/* && " + + "wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz.md5 && " + + "wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz && " + + "md5sum -c ffmpeg-git-amd64-static.tar.xz.md5 && " + + "tar xvf ffmpeg-git-amd64-static.tar.xz -C /usr/bin --strip-components=1 --no-anchored 'ffmpeg' 'ffprobe' && " + + "rm ffmpeg-git-amd64-static.tar.xz*", + ], + }, + deploy: { + env: { + FFMPEG_PATH: "/usr/bin/ffmpeg", + FFPROBE_PATH: "/usr/bin/ffprobe", + }, + override: true, + }, + }); + return; + } else if (options.version) { + context.logger.warn("Custom ffmpeg version not supported, ignoring", { + version: options.version, + }); + } + + // Default: use apt context.addLayer({ id: "ffmpeg", image: { - pkgs: options.version ? [`ffmpeg=${options.version}`] : ["ffmpeg"], + pkgs: ["ffmpeg"], }, deploy: { env: {