fix gif rendering in safari

This commit is contained in:
Sam Lavigne 2023-08-31 16:07:48 -04:00
parent d2006bcc77
commit b54aa4e82b
1 changed files with 8 additions and 2 deletions

View File

@ -91,15 +91,21 @@
clist.shift(); // remove "ffmpeg" from start of command clist.shift(); // remove "ffmpeg" from start of command
clist.unshift("-hide_banner", "-loglevel", "error"); clist.unshift("-hide_banner", "-loglevel", "error");
clist = clist.map((c) => c.replaceAll('"', "")); clist = clist.map((c) => c.replaceAll('"', ""));
let contentType = "video/mp4";
if (outname.endsWith("mp4")) { if (outname.endsWith("mp4")) {
clist.splice(clist.length - 1, 0, "-pix_fmt"); clist.splice(clist.length - 1, 0, "-pix_fmt");
clist.splice(clist.length - 1, 0, "yuv420p"); clist.splice(clist.length - 1, 0, "yuv420p");
clist.splice(clist.length - 1, 0, "-preset"); clist.splice(clist.length - 1, 0, "-preset");
clist.splice(clist.length - 1, 0, "ultrafast"); clist.splice(clist.length - 1, 0, "ultrafast");
} else {
contentType = "image/gif";
} }
await ffmpeg.exec(clist, TIMEOUT); await ffmpeg.exec(clist, TIMEOUT);
const data = await ffmpeg.readFile(outname); const data = await ffmpeg.readFile(outname);
videoValue = URL.createObjectURL(new Blob([data.buffer], { type: "video/mp4" })); videoValue = URL.createObjectURL(new Blob([data.buffer], { type: contentType }));
if (outname.endsWith("mp4")) { if (outname.endsWith("mp4")) {
setTimeout(() => { setTimeout(() => {
vidPlayerRef.seekToNextFrame(); vidPlayerRef.seekToNextFrame();