π₯ Make videos programmatically with React
Upgrade Mediabunny to 1.34.2, add AC-3 support
Ayushman09ad5dc17387
diff --git a/bun.lock b/bun.lockindex 8cd08e0861..b355e76cd7 100644--- a/bun.lock+++ b/bun.lock@@ -920,6 +920,7 @@"name": "@remotion/media","version": "4.0.410","dependencies": {+ "@mediabunny/ac3": "catalog:","mediabunny": "catalog:","remotion": "workspace:*",},@@ -2155,6 +2156,7 @@"name": "@remotion/web-renderer","version": "4.0.410","dependencies": {+ "@mediabunny/ac3": "catalog:","@remotion/licensing": "workspace:*","mediabunny": "catalog:","remotion": "workspace:*",@@ -2240,7 +2242,8 @@"@aws-sdk/lib-storage": "3.936.0","@aws-sdk/middleware-flexible-checksums": "3.936.0","@aws-sdk/s3-request-presigner": "3.936.0",- "@mediabunny/mp3-encoder": "1.29.0",+ "@mediabunny/ac3": "1.34.2",+ "@mediabunny/mp3-encoder": "1.34.2","@react-three/fiber": "9.2.0","@types/bun": "1.3.3","@types/dom-webcodecs": "0.1.11",@@ -2253,7 +2256,7 @@"@vitejs/plugin-react": "4.1.0","@vitest/browser-playwright": "4.0.9","eslint": "9.19.0",- "mediabunny": "1.29.0",+ "mediabunny": "1.34.2","next": "16.0.10","openai": "4.67.1","playwright": "1.55.1",@@ -3176,7 +3179,9 @@"@mdx-js/react": ["@mdx-js/[email protected]", "", { "dependencies": { "@types/mdx": "2.0.5", "@types/react": "19.0.0" }, "peerDependencies": { "react": "19.0.0" } }, "sha512-zQH//gdOmuu7nt2oJR29vFhDv88oGPmVw6BggmrHeMI+xgEkp1B2dX9/bMBSYtK0dyLX/aOmesKS09g222K1/g=="],- "@mediabunny/mp3-encoder": ["@mediabunny/[email protected]", "", { "peerDependencies": { "mediabunny": "^1.0.0" } }, "sha512-CEgaVOG4kxjB5CImqTRLI4QvnE0K++SVegPNFzw1LGijy1UfrRqSLMkuCn+m0B6XzMIxB3SzPHTFcdsLfPVERA=="],+ "@mediabunny/ac3": ["@mediabunny/[email protected]", "", { "peerDependencies": { "mediabunny": "^1.0.0" } }, "sha512-Ej6Ns6/NcuvtajNxiK0rrGqnTD4JQETL2Ofrdnf5lQ2vxBEXT4Od9N+RUTxQbPRX9ZlWXpwvSZgf0sdCT0P1YA=="],++ "@mediabunny/mp3-encoder": ["@mediabunny/[email protected]", "", { "peerDependencies": { "mediabunny": "^1.0.0" } }, "sha512-orRlKJBlhI6DizotCdYLqPuXn3H9S+rQM3GE/UX/F7z7oPAL4YTy2OVPAFxc0OMp1fmOAaiQZ8uTRYdM/m9pAg=="],"@mediafox/core": ["@mediafox/[email protected]", "", { "peerDependencies": { "mediabunny": "^1.23.0", "typescript": ">=5.0.0" } }, "sha512-1j8PKp835RUVzZt1vcymrgZqhaMobfP7SswbTisusvTgIZL8y5n2QFhSCnn7dze+a53VgnWyzkHOYdtVR1Gdew=="],@@ -6062,7 +6067,7 @@"media-typer": ["[email protected]", "", {}, "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ=="],- "mediabunny": ["[email protected]", "", { "dependencies": { "@types/dom-mediacapture-transform": "^0.1.11", "@types/dom-webcodecs": "0.1.13" } }, "sha512-18B8w/rhO/ph/AFsIXvzZg8RaSQZ+ZYfJ99MZlTjDmlgCT58jV3azrnWQ/OSquYDi8q0xmn64mnfTEHgww3+zw=="],+ "mediabunny": ["[email protected]", "", { "dependencies": { "@types/dom-mediacapture-transform": "^0.1.11", "@types/dom-webcodecs": "0.1.13" } }, "sha512-Mr9VhiqH2RRwc3vR6rk8ca/58HhstP+c25PjtZmZvmCw21ibWSNqpinvBREfJmY+hpNGnG9dUmbJ4WqLMDWO0g=="],"memfs": ["[email protected]", "", { "dependencies": { "fs-monkey": "1.0.3" } }, "sha512-eivjfi7Ahr6eQTn44nvTnR60e4a1Fs1Via2kCR5lHo/kyNoiMWaXCNJ/GpSd0ilXas2JSOl9B5FTIhflXu0hlg=="],@@ -10140,6 +10145,8 @@"template-ai-video/uuid": ["[email protected]", "", { "bin": { "uuid": "dist-node/bin/uuid" } }, "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w=="],+ "template-music-visualization/mediabunny": ["[email protected]", "", { "dependencies": { "@types/dom-mediacapture-transform": "^0.1.11", "@types/dom-webcodecs": "0.1.13" } }, "sha512-18B8w/rhO/ph/AFsIXvzZg8RaSQZ+ZYfJ99MZlTjDmlgCT58jV3azrnWQ/OSquYDi8q0xmn64mnfTEHgww3+zw=="],+"template-next-app/@eslint/js": ["@eslint/[email protected]", "", {}, "sha512-UZ1VpFvXf9J06YG9xQBdnzU+kthors6KjhMAl6f4gH4usHyh31rUf2DLGInT8RFYIReYXNSydgPY0V2LuWgl7A=="],"template-next-app/@typescript-eslint/eslint-plugin": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.46.0", "@typescript-eslint/type-utils": "8.46.0", "@typescript-eslint/utils": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0", "graphemer": "^1.4.0", "ignore": "^7.0.0", "natural-compare": "^1.4.0", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.46.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-hA8gxBq4ukonVXPy0OKhiaUh/68D0E88GSmtC1iAEnGaieuDi38LhS7jdCHRLi6ErJBNDGCzvh5EnzdPwUc0DA=="],@@ -10228,6 +10235,8 @@"template-recorder/lucide-react": ["[email protected]", "", { "peerDependencies": { "react": "19.0.0" } }, "sha512-aybBJzLHcw1CIn3rUcRkztB37dsJATtpffLNX+0/w+ws2p21nYIlOwX/B5fqxq8F/BjqVemnJX8chKwRidvROg=="],+ "template-recorder/mediabunny": ["[email protected]", "", { "dependencies": { "@types/dom-mediacapture-transform": "^0.1.11", "@types/dom-webcodecs": "0.1.13" } }, "sha512-18B8w/rhO/ph/AFsIXvzZg8RaSQZ+ZYfJ99MZlTjDmlgCT58jV3azrnWQ/OSquYDi8q0xmn64mnfTEHgww3+zw=="],+"template-recorder/postcss": ["[email protected]", "", { "dependencies": { "nanoid": "3.3.11", "picocolors": "1.1.1", "source-map-js": "1.2.1" } }, "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ=="],"template-recorder/prettier-plugin-organize-imports": ["[email protected]", "", { "peerDependencies": { "prettier": "3.6.0", "typescript": "5.8.2" } }, "sha512-KFvk8C/zGyvUaE3RvxN2MhCLwzV6OBbFSkwZ2OamCrs9ZY4i5L77jQ/w4UmUr+lqX8qbaqVq6bZZkApn+IgJSg=="],@@ -10248,6 +10257,8 @@"template-still/p-limit": ["[email protected]", "", { "dependencies": { "yocto-queue": "0.1.0" } }, "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ=="],+ "template-three/mediabunny": ["[email protected]", "", { "dependencies": { "@types/dom-mediacapture-transform": "^0.1.11", "@types/dom-webcodecs": "0.1.13" } }, "sha512-18B8w/rhO/ph/AFsIXvzZg8RaSQZ+ZYfJ99MZlTjDmlgCT58jV3azrnWQ/OSquYDi8q0xmn64mnfTEHgww3+zw=="],+"template-tts-azure/tsx": ["[email protected]", "", { "dependencies": { "esbuild": "0.25.0", "get-tsconfig": "4.8.1" }, "optionalDependencies": { "fsevents": "2.3.3" }, "bin": { "tsx": "dist/cli.mjs" } }, "sha512-4H8vUNGNjQ4V2EOoGw005+c+dGuPSnhpPBPHBtsZdGZBk/iJb4kguGlPWaZTZ3q5nMtFOEsY0nRDlh9PJyd6SQ=="],"template-tts-google/@types/express": ["@types/[email protected]", "", { "dependencies": { "@types/body-parser": "1.19.1", "@types/express-serve-static-core": "4.17.35", "@types/qs": "6.9.7", "@types/serve-static": "1.13.10" } }, "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA=="],@@ -12344,6 +12355,8 @@"teeny-request/https-proxy-agent/debug": ["[email protected]", "", { "dependencies": { "ms": "2.1.3" } }, "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ=="],+ "template-music-visualization/mediabunny/@types/dom-webcodecs": ["@types/[email protected]", "", {}, "sha512-O5hkiFIcjjszPIYyUSyvScyvrBoV3NOEEZx/pMlsu44TKzWNkLVBBxnxJz42in5n3QIolYOcBYFCPZZ0h8SkwQ=="],+"template-next-app-tailwind/@typescript-eslint/eslint-plugin/@typescript-eslint/scope-manager": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@typescript-eslint/types": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0" } }, "sha512-lWETPa9XGcBes4jqAMYD9fW0j4n6hrPtTJwWDmtqgFO/4HF4jmdH/Q6wggTw5qIT5TXjKzbt7GsZUBnWoO3dqw=="],"template-next-app-tailwind/@typescript-eslint/eslint-plugin/@typescript-eslint/type-utils": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@typescript-eslint/types": "8.46.0", "@typescript-eslint/typescript-estree": "8.46.0", "@typescript-eslint/utils": "8.46.0", "debug": "^4.3.4", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-hy+lvYV1lZpVs2jRaEYvgCblZxUoJiPyCemwbQZ+NGulWkQRy0HRPYAoef/CNSzaLt+MLvMptZsHXHlkEilaeg=="],@@ -12552,6 +12565,8 @@"template-recorder/lucide-react/react": ["[email protected]", "", {}, "sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ=="],+ "template-recorder/mediabunny/@types/dom-webcodecs": ["@types/[email protected]", "", {}, "sha512-O5hkiFIcjjszPIYyUSyvScyvrBoV3NOEEZx/pMlsu44TKzWNkLVBBxnxJz42in5n3QIolYOcBYFCPZZ0h8SkwQ=="],+"template-recorder/tailwindcss/postcss": ["[email protected]", "", { "dependencies": { "nanoid": "3.3.11", "picocolors": "1.1.1", "source-map-js": "1.2.1" } }, "sha512-6oz2beyjc5VMn/KV1pPw8fliQkhBXrVn1Z3TVyqZxU8kZpzEKhBdmCFqI6ZbmGtamQvQGuU1sgPTk8ZrXDD7jQ=="],"template-recorder/tailwindcss/resolve": ["[email protected]", "", { "dependencies": { "is-core-module": "2.15.1", "path-parse": "1.0.7", "supports-preserve-symlinks-flag": "1.0.0" }, "bin": { "resolve": "bin/resolve" } }, "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw=="],@@ -12588,6 +12603,8 @@"template-still/p-limit/yocto-queue": ["[email protected]", "", {}, "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="],+ "template-three/mediabunny/@types/dom-webcodecs": ["@types/[email protected]", "", {}, "sha512-O5hkiFIcjjszPIYyUSyvScyvrBoV3NOEEZx/pMlsu44TKzWNkLVBBxnxJz42in5n3QIolYOcBYFCPZZ0h8SkwQ=="],+"template-tts-google/@types/express/@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/mime": "1.3.2", "@types/node": "20.12.14" } }, "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ=="],"terser-webpack-plugin/@swc/core/@swc/core-darwin-arm64": ["@swc/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-TIus1/SE/Ud4g84hCnchcagu+LfyndSDy5r5qf64nflojejDidPU9Fp1InzQhQpEgIpntnZID/KFCP5rQnvsIw=="],diff --git a/package.json b/package.jsonindex 9fbe36762c..f40e19b905 100644--- a/package.json+++ b/package.json@@ -99,8 +99,9 @@"@types/node": "20.12.14","@types/web": "0.0.166","@types/bun": "1.3.3",- "mediabunny": "1.29.0",- "@mediabunny/mp3-encoder": "1.29.0",+ "mediabunny": "1.34.2",+ "@mediabunny/mp3-encoder": "1.34.2",+ "@mediabunny/ac3": "1.34.2","next": "16.0.10","three": "0.178.0","sharp": "0.34.5",diff --git a/packages/docs/docs/mediabunny/formats.mdx b/packages/docs/docs/mediabunny/formats.mdxindex c480122302..5b72fb27e2 100644--- a/packages/docs/docs/mediabunny/formats.mdx+++ b/packages/docs/docs/mediabunny/formats.mdx@@ -47,6 +47,8 @@ This means that during rendering of Remotion videos server-side, HEVC videos can- `'mp3'` - MP3- `'vorbis'` - Vorbis- `'flac'` - Free Lossless Audio Codec (FLAC)+- `'ac3'` - Dolby Digital (AC-3)+- `'eac3'` - Dolby Digital Plus (E-AC-3)- `'pcm-u8'` - 8-bit unsigned PCM- `'pcm-s8'` - 8-bit signed PCM- `'pcm-s16'` - 16-bit little-endian signed PCM@@ -66,32 +68,34 @@ This means that during rendering of Remotion videos server-side, HEVC videos canNot all codecs can be used with all containers. The following table specifies the supported codec-container combinations:-| | .mp4 | .mov | .mkv | .webm | .ogg | .mp3 | .wav | .aac | .flac | .ts |-| :-----------: | :--: | :--: | :--: | :---: | :--: | :--: | :--: | :--: | :---: | :--: |-| `'avc'` | β | β | β | | | | | | | β |-| `'hevc'` | β | β | β | | | | | | | β |-| `'vp8'` | β | β | β | β | | | | | | |-| `'vp9'` | β | β | β | β | | | | | | |-| `'av1'` | β | β | β | β | | | | | | |-| `'aac'` | β | β | β | | | | | β | | β |-| `'opus'` | β | β | β | β | β | | | | | |-| `'mp3'` | β | β | β | | | β | | | | β |-| `'vorbis'` | β | β | β | β | β | | | | | |-| `'flac'` | β | β | β | | | | | | β | |-| `'pcm-u8'` | | β | β | | | | β | | | |-| `'pcm-s8'` | | β | | | | | | | | |-| `'pcm-s16'` | β | β | β | | | | β | | | |-| `'pcm-s16be'` | β | β | β | | | | | | | |-| `'pcm-s24'` | β | β | β | | | | β | | | |-| `'pcm-s24be'` | β | β | β | | | | | | | |-| `'pcm-s32'` | β | β | β | | | | β | | | |-| `'pcm-s32be'` | β | β | β | | | | | | | |-| `'pcm-f32'` | β | β | β | | | | β | | | |-| `'pcm-f32be'` | β | β | | | | | | | | |-| `'pcm-f64'` | β | β | β | | | | | | | |-| `'pcm-f64be'` | β | β | | | | | | | | |-| `'ulaw'` | | β | | | | | β | | | |-| `'alaw'` | | β | | | | | β | | | |+| | .mp4 | .mov | .mkv | .webm | .ogg | .mp3 | .wav | .aac | .flac | .ts |+| :-----------: | :--: | :--: | :--: | :---: | :--: | :--: | :--: | :--: | :---: | :-: |+| `'avc'` | β | β | β | | | | | | | β |+| `'hevc'` | β | β | β | | | | | | | β |+| `'vp8'` | β | β | β | β | | | | | | |+| `'vp9'` | β | β | β | β | | | | | | |+| `'av1'` | β | β | β | β | | | | | | |+| `'aac'` | β | β | β | | | | | β | | β |+| `'opus'` | β | β | β | β | β | | | | | |+| `'mp3'` | β | β | β | | | β | | | | β |+| `'vorbis'` | β | β | β | β | β | | | | | |+| `'flac'` | β | β | β | | | | | | β | |+| `'ac3'` | β | β | β | | | | | | | β |+| `'eac3'` | β | β | β | | | | | | | β |+| `'pcm-u8'` | | β | β | | | | β | | | |+| `'pcm-s8'` | | β | | | | | | | | |+| `'pcm-s16'` | β | β | β | | | | β | | | |+| `'pcm-s16be'` | β | β | β | | | | | | | |+| `'pcm-s24'` | β | β | β | | | | β | | | |+| `'pcm-s24be'` | β | β | β | | | | | | | |+| `'pcm-s32'` | β | β | β | | | | β | | | |+| `'pcm-s32be'` | β | β | β | | | | | | | |+| `'pcm-f32'` | β | β | β | | | | β | | | |+| `'pcm-f32be'` | β | β | | | | | | | | |+| `'pcm-f64'` | β | β | β | | | | | | | |+| `'pcm-f64be'` | β | β | | | | | | | | |+| `'ulaw'` | | β | | | | | β | | | |+| `'alaw'` | | β | | | | | β | | | |## CORSdiff --git a/packages/media/package.json b/packages/media/package.jsonindex 1496d27eba..696fece376 100644--- a/packages/media/package.json+++ b/packages/media/package.json@@ -23,6 +23,7 @@},"dependencies": {"mediabunny": "catalog:",+ "@mediabunny/ac3": "catalog:","remotion": "workspace:*"},"peerDependencies": {diff --git a/packages/media/src/media-player.ts b/packages/media/src/media-player.tsindex 76a221b528..fd6f86eb8d 100644--- a/packages/media/src/media-player.ts+++ b/packages/media/src/media-player.ts@@ -1,3 +1,4 @@+import {registerAc3Decoder} from '@mediabunny/ac3';import {ALL_FORMATS, Input, UrlSource} from 'mediabunny';import type {LogLevel, useBufferState} from 'remotion';import {Internals} from 'remotion';@@ -15,6 +16,8 @@ import {makeNonceManager} from './nonce-manager';import type {VideoIteratorManager} from './video-iterator-manager';import {videoIteratorManager} from './video-iterator-manager';+registerAc3Decoder();+export type MediaPlayerInitResult =| {type: 'success'; durationInSeconds: number}| {type: 'unknown-container-format'}diff --git a/packages/web-renderer/package.json b/packages/web-renderer/package.jsonindex 534f5ccc41..1d261c95f5 100644--- a/packages/web-renderer/package.json+++ b/packages/web-renderer/package.json@@ -21,7 +21,8 @@"dependencies": {"@remotion/licensing": "workspace:*","remotion": "workspace:*",- "mediabunny": "catalog:"+ "mediabunny": "catalog:",+ "@mediabunny/ac3": "catalog:"},"devDependencies": {"@react-three/fiber": "catalog:",diff --git a/packages/web-renderer/src/mediabunny-mappings.ts b/packages/web-renderer/src/mediabunny-mappings.tsindex 4ea1ce2f04..42501f3565 100644--- a/packages/web-renderer/src/mediabunny-mappings.ts+++ b/packages/web-renderer/src/mediabunny-mappings.ts@@ -13,7 +13,7 @@ import {export type WebRendererVideoCodec = 'h264' | 'h265' | 'vp8' | 'vp9' | 'av1';export type WebRendererContainer = 'mp4' | 'webm';-export type WebRendererAudioCodec = 'aac' | 'opus';+export type WebRendererAudioCodec = 'aac' | 'opus' | 'ac3' | 'eac3';export type WebRendererQuality =| 'very-low'| 'low'@@ -128,7 +128,12 @@ export const getSupportedVideoCodecsForContainer = ();};-const WEB_RENDERER_AUDIO_CODECS: WebRendererAudioCodec[] = ['aac', 'opus'];+const WEB_RENDERER_AUDIO_CODECS: WebRendererAudioCodec[] = [+ 'aac',+ 'opus',+ 'ac3',+ 'eac3',+];export const getSupportedAudioCodecsForContainer = (container: WebRendererContainer,diff --git a/packages/web-renderer/src/render-media-on-web.tsx b/packages/web-renderer/src/render-media-on-web.tsxindex 269337ea27..c6d1c29c6c 100644--- a/packages/web-renderer/src/render-media-on-web.tsx+++ b/packages/web-renderer/src/render-media-on-web.tsx@@ -1,3 +1,4 @@+import {registerAc3Encoder} from '@mediabunny/ac3';import {BufferTarget, StreamTarget} from 'mediabunny';import type {CalculateMetadataFunction} from 'remotion';import {Internals, type LogLevel} from 'remotion';@@ -45,6 +46,8 @@ import {validateVideoFrame, type OnFrameCallback} from './validate-video-frame';import {waitForReady} from './wait-for-ready';import {cleanupStaleOpfsFiles, createWebFsTarget} from './web-fs-target';+registerAc3Encoder();+export type InputPropsIfHasProps<Schema extends AnyZodObject,Props,