ffmpegwasm / ffmpegwasm/ffmpeg.wasm

Chrome - unable to extract single image in mt version (Firefox works)

Ouverte
#542 2 commentaires 3 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C
Étoiles
17.8k
Forks
1.1k
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

**Describe the bug**
Chrome is unable to extract single image from mp4
Firefox is able to extract single image from mp4. Chrome is also able, but not when using the mt version

**To Reproduce**
Use mt version

`ffmpeg -hide_banner -i video.mp4 -vframes 1 -vf scale=-1:96 output.png`

```
[image2 @ 0x1073020] The specified filename 'output.png' does not contain an image sequence pattern or a pattern is invalid.
```

**Expected behavior**
An image should be outputed, just like Firefox is able to do, using same mt version

**Desktop (please complete the following information):**
- OS: Windows
- Browser: Chrome
- Version: `115.0.5790.171`

**Additional context**

Sample code (`file` is a FileInput selection result)

```typescript
const baseURL: string = "https://unpkg.com/@ffmpeg/core-mt@0.12.2/dist/esm";
const ffmpeg = new FFmpeg();
ffmpeg.on("log", ({ message }) => {
console.debug(message);
});
await ffmpeg.load({
coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, "text/javascript"),
workerURL: await toBlobURL(`${baseURL}/ffmpeg-core.worker.js`, "text/javascript"),
wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, "application/wasm"),
});

try {
// const buffer = await file.arrayBuffer();
// 4GB = 4294967296
const megabytes = 256;
const bytes = megabytes * Math.pow(1024, 2);
const buffer = await parseFile(file, bytes);
console.debug("Restricting size");
const video = new Uint8Array(buffer.slice(0, Math.min(bytes - 1, buffer.byteLength)));
ffmpeg.writeFile("video.mp4", video);
const command = ["-hide_banner", "-i", "video.mp4", "-vframes", "1", "-vf", "scale=-1:96", "output.png"];
console.debug("Executing", ["ffmpeg"].concat(command).join(" "));
await ffmpeg.exec(command);
const fileData = await ffmpeg.readFile("output.png");
console.debug(fileData);
} catch (error) {
console.error("Unable to extract thumbnail", error);
} finally {
ffmpeg.terminate();
}
```

As a mitigation, I am not using the `mt` version - this works in all browsers

```typescript
const baseURL: string = "https://unpkg.com/@ffmpeg/core@0.12.2/dist/esm";
const ffmpeg = new FFmpeg();
ffmpeg.on("log", ({ message }) => {
console.debug(message);
});
await ffmpeg.load({
coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, "text/javascript"),
wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, "application/wasm"),
});
```

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.