Skip to content

Commit 81c1f45

Browse files
committed
Docs and example apps for 0.13
The example apps load @ffmpeg/core 0.13 (single-threaded, no cross-origin isolation needed); none of them passes workerURL any more, as neither core has ffmpeg-core.worker.js. The migration guide covers 0.13, and the core contribution guide the FFmpeg patches and the single-threaded core's green threads.
1 parent 1b2414c commit 81c1f45

12 files changed

Lines changed: 47 additions & 46 deletions

File tree

‎apps/angular-app/src/app/app.component.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { RouterOutlet } from '@angular/router';
44
import { FFmpeg } from '@ffmpeg/ffmpeg';
55
import { fetchFile, toBlobURL } from '@ffmpeg/util';
66

7-
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core-mt@0.12.10/dist/esm';
7+
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/esm';
88

99
@Component({
1010
selector: 'app-root',
@@ -28,10 +28,6 @@ export class AppComponent {
2828
`${baseURL}/ffmpeg-core.wasm`,
2929
'application/wasm',
3030
),
31-
workerURL: await toBlobURL(
32-
`${baseURL}/ffmpeg-core.worker.js`,
33-
'text/javascript',
34-
),
3531
});
3632
this.loaded = true;
3733
}

‎apps/nextjs-app/app/Home.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function Home() {
1313

1414
const load = async () => {
1515
setIsLoading(true);
16-
const baseURL = "https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.10/dist/umd";
16+
const baseURL = "https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/umd";
1717
const ffmpeg = ffmpegRef.current;
1818
ffmpeg.on("log", ({ message }) => {
1919
if (messageRef.current) messageRef.current.innerHTML = message;

‎apps/react-vite-app/src/App.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function App() {
99
const messageRef = useRef<HTMLParagraphElement | null>(null);
1010

1111
const load = async () => {
12-
const baseURL = "https://cdn.jsdelivr.net/npm/@ffmpeg/core-mt@0.12.10/dist/esm";
12+
const baseURL = "https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/esm";
1313
const ffmpeg = ffmpegRef.current;
1414
ffmpeg.on("log", ({ message }) => {
1515
if (messageRef.current) messageRef.current.innerHTML = message;
@@ -22,10 +22,6 @@ function App() {
2222
`${baseURL}/ffmpeg-core.wasm`,
2323
"application/wasm"
2424
),
25-
workerURL: await toBlobURL(
26-
`${baseURL}/ffmpeg-core.worker.js`,
27-
"text/javascript"
28-
),
2925
});
3026
setLoaded(true);
3127
};

‎apps/solidstart-app/src/entry-server.tsx‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
// @refresh reload
22
import { createHandler, StartServer } from '@solidjs/start/server';
3-
import { HttpHeader, HttpStatusCode } from '@solidjs/start';
43

54
export default createHandler(() => (
65
<StartServer
76
document={({ assets, children, scripts }) => (
87
<html lang='en'>
9-
{/*necessary because ffmpeg library uses sharedArrayBuffer */}
10-
<HttpHeader name='Cross-Origin-Opener-Policy' value='same-origin' />
11-
<HttpHeader name='Cross-Origin-Embedder-Policy' value='require-corp' />
128
<head>
139
<meta charset='utf-8' />
1410
<meta name='viewport' content='width=device-width, initial-scale=1' />

‎apps/solidstart-app/src/routes/index.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FFmpeg } from '@ffmpeg/ffmpeg';
22
import { fetchFile, toBlobURL } from '@ffmpeg/util';
33
import { createSignal, Show } from 'solid-js';
44

5-
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core-mt@0.12.10/dist/esm';
5+
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/esm';
66
const videoURL =
77
'https://raw.githubusercontent.com/ffmpegwasm/testdata/master/video-15s.avi';
88

@@ -28,10 +28,6 @@ export default function Home() {
2828
`${baseURL}/ffmpeg-core.wasm`,
2929
'application/wasm'
3030
),
31-
workerURL: await toBlobURL(
32-
`${baseURL}/ffmpeg-core.worker.js`,
33-
'text/javascript'
34-
),
3531
});
3632
setLoaded(true);
3733
setIsLoading(false);

‎apps/sveltekit-app/src/lib/FFmpegDemo.svelte‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
let videoEl: HTMLVideoElement;
88
9-
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core-mt@0.12.10/dist/esm';
9+
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/esm';
1010
const videoURL = 'https://raw.githubusercontent.com/ffmpegwasm/testdata/master/video-15s.avi';
1111
1212
let message = 'Click Start to Transcode';
@@ -20,8 +20,7 @@
2020
});
2121
await ffmpeg.load({
2222
coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
23-
wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
24-
workerURL: await toBlobURL(`${baseURL}/ffmpeg-core.worker.js`, 'text/javascript')
23+
wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm')
2524
});
2625
message = 'Start transcoding';
2726
await ffmpeg.writeFile('test.avi', await fetchFile(videoURL));

‎apps/vue-vite-app/src/components/FFmpegDemo.vue‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { LogEvent } from '@ffmpeg/ffmpeg/dist/esm/types'
1111
import { fetchFile, toBlobURL } from '@ffmpeg/util'
1212
import { defineComponent, ref } from 'vue'
1313
14-
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core-mt@0.12.10/dist/esm'
14+
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/esm'
1515
const videoURL = 'https://raw.githubusercontent.com/ffmpegwasm/testdata/master/video-15s.avi'
1616
1717
export default defineComponent({
@@ -28,8 +28,7 @@ export default defineComponent({
2828
})
2929
await ffmpeg.load({
3030
coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
31-
wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
32-
workerURL: await toBlobURL(`${baseURL}/ffmpeg-core.worker.js`, 'text/javascript')
31+
wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm')
3332
})
3433
message.value = 'Start transcoding'
3534
await ffmpeg.writeFile('test.avi', await fetchFile(videoURL))

‎apps/website/docs/contribution/core.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ $ make prd-mt
4242
4343
The output file locates at **/packages/core** or **/packages/core-mt**.
4444

45+
## Changes to FFmpeg
46+
47+
ffmpeg.wasm builds FFmpeg at the tag in `FFMPEG_VERSION` (Dockerfile) with the
48+
patches in `patches/ffmpeg`, one per change. To change one, or add one:
49+
50+
```bash
51+
$ git clone --branch n9.0.2 https://github.com/FFmpeg/FFmpeg && cd FFmpeg
52+
$ git am ../ffmpeg.wasm/patches/ffmpeg/*.patch
53+
# edit, commit
54+
$ git format-patch --zero-commit --no-signature -o ../ffmpeg.wasm/patches/ffmpeg n9.0.2
55+
```
56+
57+
FFmpeg's command line tools need threads. `@ffmpeg/core-mt` uses real
58+
threads (Web Workers and SharedArrayBuffer); `@ffmpeg/core` runs them one at a
59+
time on a single thread with the cooperative pthreads in `src/green`.
60+
4561
## Custom Build / Reduce Build Size
4662

4763
You can customize your build to include only the libraries you need, which can significantly reduce the final build size. This is done by modifying the `Dockerfile`.

‎apps/website/docs/getting-started/usage.md‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ It is recommended to read [Overview](/docs/overview) first.
1111
:::caution
1212
If you are a [vite](https://vitejs.dev/) user, use `esm` in **baseURL** instead of `umd`:
1313

14-
~~https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.10/dist/umd~~ => https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.10/dist/esm
14+
~~https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/umd~~ => https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/esm
1515
:::
1616

1717
```jsx live
@@ -24,7 +24,7 @@ function() {
2424
const messageRef = useRef(null);
2525

2626
const load = async () => {
27-
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.10/dist/umd'
27+
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/umd'
2828
const ffmpeg = ffmpegRef.current;
2929
ffmpeg.on('log', ({ message }) => {
3030
messageRef.current.innerHTML = message;
@@ -81,7 +81,7 @@ function() {
8181
const messageRef = useRef(null);
8282

8383
const load = async () => {
84-
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core-mt@0.12.10/dist/umd'
84+
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core-mt@0.13.0/dist/umd'
8585
const ffmpeg = ffmpegRef.current;
8686
ffmpeg.on('log', ({ message }) => {
8787
messageRef.current.innerHTML = message;
@@ -92,7 +92,6 @@ function() {
9292
await ffmpeg.load({
9393
coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
9494
wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
95-
workerURL: await toBlobURL(`${baseURL}/ffmpeg-core.worker.js`, 'text/javascript'),
9695
});
9796
setLoaded(true);
9897
}
@@ -134,7 +133,7 @@ function() {
134133
const messageRef = useRef(null);
135134

136135
const load = async () => {
137-
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.10/dist/umd'
136+
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/umd'
138137
const ffmpeg = ffmpegRef.current;
139138
ffmpeg.on('log', ({ message }) => {
140139
messageRef.current.innerHTML = message;
@@ -192,7 +191,7 @@ function() {
192191
const messageRef = useRef(null);
193192

194193
const load = async () => {
195-
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.10/dist/umd'
194+
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/umd'
196195
const ffmpeg = ffmpegRef.current;
197196
// Listen to progress event instead of log.
198197
ffmpeg.on('progress', ({ progress, time }) => {
@@ -243,7 +242,7 @@ function() {
243242
const messageRef = useRef(null);
244243

245244
const load = async () => {
246-
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.10/dist/umd'
245+
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/umd'
247246
const ffmpeg = ffmpegRef.current;
248247
ffmpeg.on('log', ({ message }) => {
249248
messageRef.current.innerHTML = message;
@@ -313,7 +312,7 @@ function() {
313312
const messageRef = useRef(null);
314313

315314
const load = async () => {
316-
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.10/dist/umd'
315+
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/umd'
317316
const ffmpeg = ffmpegRef.current;
318317
ffmpeg.on('log', ({ message }) => {
319318
messageRef.current.innerHTML = message;
@@ -372,7 +371,7 @@ function() {
372371
const messageRef = useRef(null);
373372

374373
const load = async () => {
375-
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.12.10/dist/umd'
374+
const baseURL = 'https://cdn.jsdelivr.net/npm/@ffmpeg/core@0.13.0/dist/umd'
376375
const ffmpeg = ffmpegRef.current;
377376
ffmpeg.on('log', ({ message }) => {
378377
messageRef.current.innerHTML = message;

‎apps/website/docs/migration.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ import TableHead from '@mui/material/TableHead';
77
import TableRow from '@mui/material/TableRow';
88
import Paper from '@mui/material/Paper';
99

10+
# Migrating from 0.12.x to 0.13
11+
12+
- Both cores are FFmpeg 9 (0.12 was FFmpeg 5.1).
13+
- `@ffmpeg/core` is single-threaded and needs no special headers.
14+
`@ffmpeg/core-mt` is faster, but needs a cross-origin isolated page
15+
(`Cross-Origin-Opener-Policy: same-origin` and
16+
`Cross-Origin-Embedder-Policy: require-corp` or `credentialless`); without
17+
it `ffmpeg.load()` rejects with an explanation.
18+
- There is no `ffmpeg-core.worker.js` any more, and the `workerURL` option of
19+
`load()` is ignored.
20+
- `exec()` and `ffprobe()` return FFmpeg's exit code: `0` on success, `1` on
21+
timeout, and otherwise a non-zero value (often a negative error code) instead
22+
of always `1`. A command that crashes now rejects instead of resolving.
23+
1024
# Migrating from 0.11.x to 0.12+
1125

1226
As 0.12+ is not backward compatible with 0.11.x, below is a quick mapping

0 commit comments

Comments
 (0)