Fix mp4 export on macOS
This commit is contained in:
parent
494c92489b
commit
eceadb0a27
29
src/main.js
29
src/main.js
|
|
@ -4883,14 +4883,19 @@ function downloadObjectURL(url, filename) {
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function done(output) {
|
async function done(output, path) {
|
||||||
const url = URL.createObjectURL(output);
|
await writeFile(
|
||||||
downloadObjectURL(url, "test.mp4")
|
path, // The destination file path for saving
|
||||||
|
new Uint8Array(await output.arrayBuffer()),
|
||||||
|
);
|
||||||
|
// const url = URL.createObjectURL(output);
|
||||||
|
// downloadObjectURL(url, "test.mp4")
|
||||||
const modal = document.getElementById('progressModal');
|
const modal = document.getElementById('progressModal');
|
||||||
modal.style.display = 'none';
|
modal.style.display = 'none';
|
||||||
|
document.querySelector("body").style.cursor = "default";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function exportMp4() {
|
async function exportMp4(path) {
|
||||||
const worker = new Worker("/ffmpeg-worker-mp4.js")
|
const worker = new Worker("/ffmpeg-worker-mp4.js")
|
||||||
// const worker = new Worker("/ffmpeg-worker-webm.js")
|
// const worker = new Worker("/ffmpeg-worker-webm.js")
|
||||||
|
|
||||||
|
|
@ -5041,7 +5046,7 @@ async function exportMp4() {
|
||||||
type: "video/mp4"
|
type: "video/mp4"
|
||||||
});
|
});
|
||||||
// Trigger the done callback with the final video blob
|
// Trigger the done callback with the final video blob
|
||||||
done(finalBlob);
|
done(finalBlob, path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5100,7 +5105,7 @@ async function exportMp4() {
|
||||||
type: "video/mp4"
|
type: "video/mp4"
|
||||||
});
|
});
|
||||||
// Trigger the done callback with the final video blob
|
// Trigger the done callback with the final video blob
|
||||||
done(finalBlob);
|
done(finalBlob, path);
|
||||||
break;
|
break;
|
||||||
case 'stderr':
|
case 'stderr':
|
||||||
console.log(msg.data);
|
console.log(msg.data);
|
||||||
|
|
@ -5154,11 +5159,13 @@ async function exportMp4() {
|
||||||
// exportMp4()
|
// exportMp4()
|
||||||
|
|
||||||
async function render() {
|
async function render() {
|
||||||
exportMp4()
|
|
||||||
return
|
|
||||||
document.querySelector("body").style.cursor = "wait";
|
document.querySelector("body").style.cursor = "wait";
|
||||||
const path = await saveFileDialog({
|
const path = await saveFileDialog({
|
||||||
filters: [
|
filters: [
|
||||||
|
{
|
||||||
|
name: "MP4 files (.mp4)",
|
||||||
|
extensions: ["mp4"],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "APNG files (.png)",
|
name: "APNG files (.png)",
|
||||||
extensions: ["png"],
|
extensions: ["png"],
|
||||||
|
|
@ -5168,7 +5175,7 @@ async function render() {
|
||||||
extensions: ["html"],
|
extensions: ["html"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
defaultPath: await join(await documentDir(), "untitled.png"),
|
defaultPath: await join(await documentDir(), "untitled.mp4"),
|
||||||
});
|
});
|
||||||
if (path != undefined) {
|
if (path != undefined) {
|
||||||
// SVG balks on images
|
// SVG balks on images
|
||||||
|
|
@ -5183,6 +5190,10 @@ async function render() {
|
||||||
const ext = path.split(".").pop().toLowerCase();
|
const ext = path.split(".").pop().toLowerCase();
|
||||||
|
|
||||||
switch (ext) {
|
switch (ext) {
|
||||||
|
case "mp4":
|
||||||
|
exportMp4(path)
|
||||||
|
return
|
||||||
|
break
|
||||||
case "html":
|
case "html":
|
||||||
fetch("/player.html")
|
fetch("/player.html")
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue