From f145882a4e5ddf3eeede946cd03ed2ed8c357d89 Mon Sep 17 00:00:00 2001 From: Sam Lavigne Date: Sun, 20 Aug 2023 13:44:36 -0400 Subject: [PATCH] add error handling to render --- src/App.svelte | 89 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 71 insertions(+), 18 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 6694936..46edee8 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -17,7 +17,6 @@ const ffmpeg = new FFmpeg(); let command = ""; - let message = ""; let videoValue = "/" + $inputs[0]; let ffmpegLoaded = false; let rendering = false; @@ -39,20 +38,22 @@ } async function transcode() { - message = "Start transcoding"; videoValue = null; rendering = true; - for (let vid of $inputs) { - await ffmpeg.writeFile(vid, await fetchFile("/" + vid)); + try { + for (let vid of $inputs) { + await ffmpeg.writeFile(vid, await fetchFile("/" + vid)); + } + const clist = commandList(); + console.log(clist); + await ffmpeg.exec(clist, TIMEOUT); + // await ffmpeg.exec(["-f", "lavfi", "-i", "color=size=1280x720:rate=25:color=red", "-t", "5", "out.mp4"]) + const data = await ffmpeg.readFile("out.mp4"); + rendering = false; + videoValue = URL.createObjectURL(new Blob([data.buffer], { type: "video/mp4" })); + } catch (e) { + log += "Failed"; } - const clist = commandList(); - console.log(clist); - await ffmpeg.exec(clist, TIMEOUT); - // await ffmpeg.exec(["-f", "lavfi", "-i", "color=size=1280x720:rate=25:color=red", "-t", "5", "out.mp4"]) - message = "Complete transcoding"; - const data = await ffmpeg.readFile("out.mp4"); - rendering = false; - videoValue = URL.createObjectURL(new Blob([data.buffer], { type: "video/mp4" })); rendering = false; } @@ -61,7 +62,6 @@ console.log(msg); log += msg + "\n"; logbox.scrollTop = logbox.scrollHeight; - // message = msg; }); if (isChrome) { await ffmpeg.load({ @@ -154,10 +154,14 @@

FFmpeg Explorer

- A tool to help you explore FFmpeg filters and options. To use: select one or more input videos - (there are currently two options), export and add some filters, and then hit "render" to - preview the output in browser. Note: this is a work in progress, many things may still be - broken, and only audio->audio and video->video filters are included. By Sam Lavigne. + A tool to help you explore FFmpeg + filters and options. To use: select one or more input videos (there are currently two options), + export and add some filters, and then hit "render" to preview the output in browser. Note: this + is a work in progress, many things may still be broken! Only audio to audio and video to video + filters are included. If it hangs/crashes refresh the page. Post issues/feedback to + GitHub. By Sam Lavigne.

@@ -239,12 +243,14 @@ "out log prv" "flt flt flt"; grid-gap: 20px; + padding: 20px; } section { border: 1px solid #999; padding: 10px; background-color: rgb(245, 245, 245); + box-shadow: 7px 7px 0px rgba(0, 0, 0, 0.7); } .header { @@ -284,7 +290,8 @@ .filter-picker { max-height: 500px; - max-width: 400px; + width: 400px; + position: sticky; top: 0; left: 0; @@ -293,6 +300,7 @@ } .filters-holder { + min-height: 500px; display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 10px; @@ -310,6 +318,9 @@ margin: 0; padding: 0; } + h1 { + margin-bottom: 5px; + } h3 { margin-bottom: 10px; } @@ -329,6 +340,7 @@ resize: none; flex: 1; font: inherit; + padding: 5px; } .section-header { display: flex; @@ -353,4 +365,45 @@ align-items: center; justify-content: center; } + + @media only screen and (max-width: 600px) { + main { + grid-template-areas: + "hdr hdr hdr" + "cmd cmd cmd" + "inp inp inp" + "out out out" + "prv prv prv" + "log log log" + "flt flt flt"; + grid-gap: 0px; + padding: 0px; + } + .command { + margin: 0; + margin-bottom: 10px; + } + section { + box-shadow: none; + margin-bottom: 10px; + padding: 10px; + box-shadow: 2px 2px 0px #000; + } + .inner-filters { + display: block; + } + .filter-picker { + width: 100%; + margin-bottom: 20px; + height: 300px; + position: static; + } + .filters-holder { + grid-template-columns: repeat(1, 1fr); + grid-gap: 10px; + flex: 1; + align-content: start; + padding: 0; + } + }