This commit is contained in:
Sam Lavigne 2023-08-19 15:17:59 -04:00
parent a9ad1439f8
commit 0fcdfacda8
1 changed files with 48 additions and 42 deletions

View File

@ -1,5 +1,5 @@
<script>
import { onMount } from 'svelte';
import { onMount } from "svelte";
import { inputs, output, filters } from "./stores.js";
import Input from "./Input.svelte";
import Output from "./Output.svelte";
@ -10,6 +10,7 @@
import { fetchFile, toBlobURL } from "@ffmpeg/util";
const baseURL = "https://unpkg.com/@ffmpeg/core-mt@0.12.2/dist/esm";
// const baseURL = "";
// const videoURL = "https://ffmpegwasm.netlify.app/video/video-15s.avi";
const videoURL = "/example.mp4";
const TIMEOUT = 40000;
@ -35,7 +36,6 @@
transcode();
}
async function transcode() {
// try {
message = "Start transcoding";
@ -92,16 +92,12 @@
return out;
}
function commandList() {
let command = ["-i", "example.mp4"];
const cFilters = $filters
.map((f) => {
function makeFilterArgs(f) {
let fCommand = f.name;
if (f.params && f.params.length > 0) {
let params = f.params
.map((p) => {
if (p.value === "" || p.value === null || p.value===p.default) return null;
if (p.value === "" || p.value === null || p.value === p.default) return null;
return `${p.name}=${p.value}`;
})
.filter((p) => p !== null)
@ -109,8 +105,15 @@
fCommand += "=" + params;
}
return fCommand;
})
.join(",");
}
function commandList() {
let command = ["-i", "example.mp4"];
// const audioFilters = $filters.filter(f => f.type[0] === "A").map(makeFilterArgs);
// const videoFilters = $filters.filter(f => f.type[0] === "V").map(makeFilterArgs);
const cFilters = $filters.map(makeFilterArgs).join(",");
if (cFilters.length > 0) {
command.push("-filter_complex");
@ -133,6 +136,9 @@
// message = msg;
});
await ffmpeg.load({
// coreURL: `${baseURL}/ffmpeg-core.js`,
// wasmURL: `${baseURL}/ffmpeg-core.wasm`,
// workerURL: `${baseURL}/ffmpeg-core.worker.js`,
coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, "text/javascript"),
wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, "application/wasm"),
workerURL: await toBlobURL(`${baseURL}/ffmpeg-core.worker.js`, "text/javascript"),