Chrome - unable to extract single image in mt version (Firefox works)
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)
const baseURL: string = "https://unpkg.com/@ffmpeg/[email protected]/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
const baseURL: string = "https://unpkg.com/@ffmpeg/[email protected]/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"),
});
Considering your use case, I would suggest to stick with single thread version as mt is very unstable and introduces a lot of limitations.
Experiencing the same problem here. When using mt version with '-vf' filter, there's no output nor error.
OS: macOS 14.1.2 (Apple M1 Pro) Browser: Chrome Version: 121.0.6167.184