Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Add node ffprobe support to audio extraction

Richie McIlroy90535d268fe6
diff --git a/apps/web/__tests__/unit/audio-extract.test.ts b/apps/web/__tests__/unit/audio-extract.test.ts
index 1fac4d667..2b2ce84af 100644
--- a/apps/web/__tests__/unit/audio-extract.test.ts
+++ b/apps/web/__tests__/unit/audio-extract.test.ts
@@ -5,6 +5,10 @@ vi.mock("@ffmpeg-installer/ffmpeg", () => ({
path: "/usr/local/bin/ffmpeg",
}));
+vi.mock("@ffprobe-installer/ffprobe", () => ({
+ path: "/usr/local/bin/ffprobe",
+}));
+
const mockUnlink = vi.fn().mockResolvedValue(undefined);
vi.mock("node:fs", () => ({
promises: {
@@ -60,6 +64,7 @@ vi.mock("fluent-ffmpeg", () => {
const ffmpeg = vi.fn(() => createChain());
(ffmpeg as Record<string, unknown>).setFfmpegPath = vi.fn();
+ (ffmpeg as Record<string, unknown>).setFfprobePath = vi.fn();
(ffmpeg as Record<string, unknown>).ffprobe = (
_url: string,
cb: (err: Error | null, data: unknown) => void,
diff --git a/apps/web/lib/audio-extract.ts b/apps/web/lib/audio-extract.ts
index 29fad9bfe..da62859fb 100644
--- a/apps/web/lib/audio-extract.ts
+++ b/apps/web/lib/audio-extract.ts
@@ -3,9 +3,11 @@ import { promises as fs } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { path as ffmpegPath } from "@ffmpeg-installer/ffmpeg";
+import { path as ffprobePath } from "@ffprobe-installer/ffprobe";
import ffmpeg, { type FfprobeData } from "fluent-ffmpeg";
ffmpeg.setFfmpegPath(ffmpegPath);
+ffmpeg.setFfprobePath(ffprobePath);
export interface AudioExtractionResult {
filePath: string;
diff --git a/apps/web/package.json b/apps/web/package.json
index cff0e2c14..c6e2c627a 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -41,6 +41,7 @@
"@effect/sql-mysql2": "^0.47.0",
"@effect/workflow": "^0.11.3",
"@ffmpeg-installer/ffmpeg": "^1.1.0",
+ "@ffprobe-installer/ffprobe": "^2.1.2",
"@fortawesome/free-brands-svg-icons": "^6.7.2",
"@fortawesome/free-solid-svg-icons": "^6.7.2",
"@fortawesome/react-fontawesome": "^0.2.2",
@@ -82,7 +83,6 @@
"@uidotdev/usehooks": "^2.4.1",
"@vercel/functions": "^3.1.0",
"@vercel/otel": "^2.0.1",
- "workflow": "^4.0.1-beta.42",
"@virtual-grid/react": "^2.0.3",
"@workos-inc/node": "^7.34.0",
"aws-sdk": "^2.1530.0",
@@ -137,17 +137,15 @@
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"tldts": "^7.0.11",
- "uuid": "^9.0.1",
"ua-parser-js": "^1.0.38",
+ "uuid": "^9.0.1",
+ "workflow": "^4.0.1-beta.42",
"zod": "^3.25.76"
},
"devDependencies": {
"@babel/plugin-transform-private-methods": "^7.27.1",
"@babel/plugin-transform-private-property-in-object": "^7.27.1",
"@smithy/types": "^4.3.1",
- "@vitest/coverage-v8": "^3.2.0",
- "@vitest/ui": "^3.2.0",
- "vitest": "^3.2.0",
"@types/canvas-confetti": "^1.9.0",
"@types/file-saver": "^2.0.7",
"@types/fluent-ffmpeg": "^2.1.27",
@@ -160,13 +158,16 @@
"@types/react-responsive-masonry": "^2.6.0",
"@types/ua-parser-js": "^0.7.39",
"@types/uuid": "^9.0.8",
+ "@vitest/coverage-v8": "^3.2.0",
+ "@vitest/ui": "^3.2.0",
"autoprefixer": "^10.4.14",
"babel-loader": "^10.0.0",
"eslint": "^9.30.1",
"eslint-config-next": "15.5.7",
"postcss": "^8.4.23",
"tailwindcss": "^3",
- "typescript": "^5.8.3"
+ "typescript": "^5.8.3",
+ "vitest": "^3.2.0"
},
"engines": {
"node": ">=20"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9037eb01a..2380faf78 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -118,7 +118,7 @@ importers:
version: 0.14.10([email protected])
'@solidjs/start':
specifier: ^1.1.3
'@tanstack/solid-query':
specifier: ^5.51.21
version: 5.75.4([email protected])
@@ -208,7 +208,7 @@ importers:
version: 9.0.1
vinxi:
specifier: ^0.5.6
webcodecs:
specifier: ^0.1.0
version: 0.1.0
@@ -437,6 +437,9 @@ importers:
'@ffmpeg-installer/ffmpeg':
specifier: ^1.1.0
version: 1.1.0
+ '@ffprobe-installer/ffprobe':
+ specifier: ^2.1.2
+ version: 2.1.2
'@fortawesome/free-brands-svg-icons':
specifier: ^6.7.2
version: 6.7.2
@@ -3538,6 +3541,50 @@ packages:
cpu: [x64]
os: [win32]
+ '@ffprobe-installer/[email protected]':
+ resolution: {integrity: sha512-vwNCNjokH8hfkbl6m95zICHwkSzhEvDC3GVBcUp5HX8+4wsX10SP3B+bGur7XUzTIZ4cQpgJmEIAx6TUwRepMg==}
+ cpu: [arm64]
+ os: [darwin]
+
+ '@ffprobe-installer/[email protected]':
+ resolution: {integrity: sha512-J+YGscZMpQclFg31O4cfVRGmDpkVsQ2fZujoUdMAAYcP0NtqpC49Hs3SWJpBdsGB4VeqOt5TTm1vSZQzs1NkhA==}
+ cpu: [x64]
+ os: [darwin]
+
+ '@ffprobe-installer/[email protected]':
+ resolution: {integrity: sha512-ZNvwk4f2magF42Zji2Ese16SMj9BS7Fui4kRjg6gTYTxY3gWZNpg85n4MIfQyI9nimHg4x/gT6FVkp/bBDuBwg==}
+ engines: {node: '>=14.21.2'}
+
+ '@ffprobe-installer/[email protected]':
+ resolution: {integrity: sha512-X1VvWtlLs6ScP73biVLuHD5ohKJKsMTa0vafCESOen4mOoNeLAYbxOVxDWAdFz9cpZgRiloFj5QD6nDj8E28yQ==}
+ cpu: [arm64]
+ os: [linux]
+
+ '@ffprobe-installer/[email protected]':
+ resolution: {integrity: sha512-PF5HqEhCY7WTWHtLDYbA/+rLS+rhslWvyBlAG1Fk8VzVlnRdl93o6hy7DE2kJgxWQbFaR3ZktPQGEzfkrmQHvQ==}
+ cpu: [arm]
+ os: [linux]
+
+ '@ffprobe-installer/[email protected]':
+ resolution: {integrity: sha512-TFVK5sasXyXhbIG7LtPRDmtkrkOsInwKcL43iEvEw+D9vCS2rc//mn9/0Q+BR0UoJEiMK4+ApYr/3LLVUBPOCQ==}
+ cpu: [ia32]
+ os: [linux]
+
+ '@ffprobe-installer/[email protected]':
+ resolution: {integrity: sha512-D3UeqTLYPNs7pBWPLUYGehPdRVqU8eACox4OZy3pZUZatxye2YKlvBwEfaLdL1v2Z4FOAlLUhms0kY8m8kqSRA==}
+ cpu: [x64]
+ os: [linux]
+
+ '@ffprobe-installer/[email protected]':
+ resolution: {integrity: sha512-5O3vOoNRxmut0/Nu9vSazTdSHasrr+zPT2B3Hm7kjmO3QVFcIfVImS6ReQnZeSy8JPJOqXts5kX5x/3KOX54XQ==}
+ cpu: [ia32]
+ os: [win32]
+
+ '@ffprobe-installer/[email protected]':
+ resolution: {integrity: sha512-jMGYeAgkrdn4e2vvYt/qakgHRE3CPju4bn5TmdPfoAm1BlX1mY9cyMd8gf5vSzI8gH8Zq5WQAyAkmekX/8TSTg==}
+ cpu: [x64]
+ os: [win32]
+
'@floating-ui/[email protected]':
resolution: {integrity: sha512-FRdBLykrPPA6P76GGGqlex/e7fbe0F1ykgxHYNXQsH/iTEtjMj/f9bpY5oQqbjt5VgZvgz/uKXbGuROijh3VLA==}
@@ -12234,6 +12281,7 @@ packages:
resolution: {integrity: sha512-+t2/0jIJ48kUpGKkdlhgkv+zPTEOoXyr60qXe68eB/pl3CMJaLeIGjzp5D6Oqt25hCBiBTt8wEeeAzfJvUKnPQ==}
engines: {node: ^18.18.0 || ^19.8.0 || >= 20.0.0}
+ deprecated: This version has a security vulnerability. Please upgrade to a patched version. See https://nextjs.org/blog/security-update-2025-12-11 for more details.
hasBin: true
peerDependencies:
'@opentelemetry/api': ^1.1.0
@@ -18322,6 +18370,41 @@ snapshots:
'@ffmpeg-installer/[email protected]':
optional: true
+ '@ffprobe-installer/[email protected]':
+ optional: true
+
+ '@ffprobe-installer/[email protected]':
+ optional: true
+
+ '@ffprobe-installer/[email protected]':
+ optionalDependencies:
+ '@ffprobe-installer/darwin-arm64': 5.0.1
+ '@ffprobe-installer/darwin-x64': 5.1.0
+ '@ffprobe-installer/linux-arm': 5.2.0
+ '@ffprobe-installer/linux-arm64': 5.2.0
+ '@ffprobe-installer/linux-ia32': 5.2.0
+ '@ffprobe-installer/linux-x64': 5.2.0
+ '@ffprobe-installer/win32-ia32': 5.1.0
+ '@ffprobe-installer/win32-x64': 5.1.0
+
+ '@ffprobe-installer/[email protected]':
+ optional: true
+
+ '@ffprobe-installer/[email protected]':
+ optional: true
+
+ '@ffprobe-installer/[email protected]':
+ optional: true
+
+ '@ffprobe-installer/[email protected]':
+ optional: true
+
+ '@ffprobe-installer/[email protected]':
+ optional: true
+
+ '@ffprobe-installer/[email protected]':
+ optional: true
+
'@floating-ui/[email protected]':
dependencies:
'@floating-ui/utils': 0.2.9
@@ -22017,11 +22100,11 @@ snapshots:
dependencies:
solid-js: 1.9.6
dependencies:
'@tanstack/server-functions-plugin': 1.119.2(@types/[email protected])([email protected])([email protected])([email protected])
defu: 6.1.4
error-stack-parser: 2.1.4
html-to-image: 1.11.13
@@ -22032,7 +22115,7 @@ snapshots:
source-map-js: 1.2.1
terracotta: 1.0.6([email protected])
tinyglobby: 0.2.13
transitivePeerDependencies:
- '@testing-library/jest-dom'
@@ -23420,7 +23503,7 @@ snapshots:
untun: 0.1.3
uqr: 0.1.2
dependencies:
'@babel/parser': 7.27.2
acorn: 8.14.1
@@ -23431,18 +23514,18 @@ snapshots:
magicast: 0.2.11
recast: 0.23.11
tslib: 2.8.1
dependencies:
acorn: 8.14.1
acorn-loose: 8.5.0
acorn-typescript: 1.4.13([email protected])
astring: 1.9.0
magicast: 0.2.11
recast: 0.23.11
'@virtual-grid/[email protected]': {}
@@ -25921,8 +26004,8 @@ snapshots:
'@typescript-eslint/parser': 5.62.0([email protected]([email protected]))([email protected])
eslint: 9.30.1([email protected])
eslint-import-resolver-node: 0.3.9
+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected]([email protected]))
eslint-plugin-jsx-a11y: 6.10.2([email protected]([email protected]))
eslint-plugin-react: 7.37.5([email protected]([email protected]))
eslint-plugin-react-hooks: 5.2.0([email protected]([email protected]))
@@ -25950,33 +26033,33 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.4.3([email protected])
- eslint: 9.30.1([email protected])
+ eslint: 8.57.1
get-tsconfig: 4.11.0
is-bun-module: 2.0.0
stable-hash: 0.0.5
tinyglobby: 0.2.15
unrs-resolver: 1.7.2
optionalDependencies:
transitivePeerDependencies:
- supports-color
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.4.3([email protected])
- eslint: 8.57.1
+ eslint: 9.30.1([email protected])
get-tsconfig: 4.11.0
is-bun-module: 2.0.0
stable-hash: 0.0.5
tinyglobby: 0.2.15
unrs-resolver: 1.7.2
optionalDependencies:
transitivePeerDependencies:
- supports-color
@@ -25991,14 +26074,14 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
'@typescript-eslint/parser': 5.62.0([email protected]([email protected]))([email protected])
eslint: 9.30.1([email protected])
eslint-import-resolver-node: 0.3.9
+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected]([email protected]))
transitivePeerDependencies:
- supports-color
@@ -26031,7 +26114,7 @@ snapshots:
- eslint-import-resolver-webpack
- supports-color
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.8
@@ -26042,7 +26125,7 @@ snapshots:
doctrine: 2.1.0
eslint: 9.30.1([email protected])
eslint-import-resolver-node: 0.3.9
hasown: 2.0.2
is-core-module: 2.16.1
is-glob: 4.0.3
@@ -28730,7 +28813,7 @@ snapshots:
cors: 2.8.5
dependencies:
'@cloudflare/kv-asset-handler': 0.4.0
'@netlify/functions': 3.1.5([email protected])([email protected])
@@ -28784,7 +28867,7 @@ snapshots:
pretty-bytes: 6.1.1
radix3: 1.1.2
rollup: 4.40.2
- rollup-plugin-visualizer: 5.14.0([email protected])
+ rollup-plugin-visualizer: 5.14.0([email protected])([email protected])
scule: 1.3.0
semver: 7.7.2
serve-placeholder: 2.0.2
@@ -30202,13 +30285,14 @@ snapshots:
dependencies:
rollup-plugin-inject: 3.0.2
dependencies:
open: 8.4.2
picomatch: 4.0.3
source-map: 0.7.4
yargs: 17.7.2
optionalDependencies:
+ rolldown: 1.0.0-beta.59
rollup: 4.40.2
@@ -32052,7 +32136,7 @@ snapshots:
d3-time: 3.1.0
d3-timer: 3.0.1
dependencies:
'@babel/core': 7.27.1
'@babel/plugin-syntax-jsx': 7.27.1(@babel/[email protected])
@@ -32074,7 +32158,7 @@ snapshots:
hookable: 5.5.3
http-proxy: 1.18.1
micromatch: 4.0.8
node-fetch-native: 1.6.6
path-to-regexp: 6.3.0
pathe: 1.1.2