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