web/queue: add a remux worker to saving pipeline, use pipelineResults

This commit is contained in:
wukko
2025-01-31 11:22:31 +06:00
parent f2325bdc24
commit 1590490db2
3 changed files with 33 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
import mime from "mime";
import { addItem } from "$lib/state/queen-bee/queue";
import type { CobaltPipelineItem } from "$lib/types/workers";
import type { CobaltLocalProcessingResponse } from "$lib/types/api";
@@ -49,7 +51,10 @@ export const createSavePipeline = (info: CobaltLocalProcessingResponse) => {
const parentId = crypto.randomUUID();
const pipeline: CobaltPipelineItem[] = [];
for (const tunnel of info.tunnel) {
// reverse is needed for audio (second item) to be downloaded first
const tunnels = info.tunnel.reverse();
for (const tunnel of tunnels) {
pipeline.push({
worker: "fetch",
workerId: crypto.randomUUID(),
@@ -60,6 +65,24 @@ export const createSavePipeline = (info: CobaltLocalProcessingResponse) => {
})
}
pipeline.push({
worker: "remux",
workerId: crypto.randomUUID(),
parentId,
workerArgs: {
ffargs: [
"-c:v", "copy",
"-c:a", "copy"
],
output: {
// TODO: return mime type from api to avoid dragging a big ass package into web build
type: mime.getType(info.filename) || undefined,
extension: info.filename.split(".").pop(),
},
filename: info.filename,
},
})
addItem({
id: parentId,
state: "waiting",