fix audio only filters
This commit is contained in:
parent
692490398f
commit
115c30466b
|
@ -109,9 +109,11 @@ export const previewCommand = derived([edges, nodes], ([$edges, $nodes]) => {
|
||||||
finalCommand.push("0:a");
|
finalCommand.push("0:a");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasVid) {
|
|
||||||
finalCommand.push("-map");
|
finalCommand.push("-map");
|
||||||
|
if (hasVid) {
|
||||||
finalCommand.push('"[vid_out]"');
|
finalCommand.push('"[vid_out]"');
|
||||||
|
} else {
|
||||||
|
finalCommand.push("0:v");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,6 +255,12 @@ export function addNode(_data, type) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resetNodes() {
|
||||||
|
nodes.set([]);
|
||||||
|
addNode({ name: "punch.mp4" }, "input");
|
||||||
|
addNode({ name: "out.mp4" }, "output");
|
||||||
|
}
|
||||||
|
|
||||||
export function removeNode(id) {
|
export function removeNode(id) {
|
||||||
nodes.update((_nodes) => {
|
nodes.update((_nodes) => {
|
||||||
const index = _nodes.findIndex((n) => n.id === id);
|
const index = _nodes.findIndex((n) => n.id === id);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { expect, test, describe } from "vitest";
|
import { expect, test, describe } from "vitest";
|
||||||
import { makeFilterArgs } from "../../src/stores.js";
|
import { get } from "svelte/store";
|
||||||
|
import { nodes, edges, addNode, resetNodes, makeFilterArgs, previewCommand } from "../../src/stores.js";
|
||||||
|
|
||||||
describe("Filter param builder", () => {
|
describe("Filter param builder", () => {
|
||||||
test("No params", () => {
|
test("No params", () => {
|
||||||
|
@ -38,7 +39,7 @@ describe("Filter param builder", () => {
|
||||||
name: "filter",
|
name: "filter",
|
||||||
params: [
|
params: [
|
||||||
{ name: "param1", value: 1, default: 1 }, // should be ignored
|
{ name: "param1", value: 1, default: 1 }, // should be ignored
|
||||||
{ name: "param2", value: "", }, // should be ignored
|
{ name: "param2", value: "" }, // should be ignored
|
||||||
{ name: "param3", value: 1, default: 2 },
|
{ name: "param3", value: 1, default: 2 },
|
||||||
{ name: "param4", value: 2 },
|
{ name: "param4", value: 2 },
|
||||||
{ name: "param5", value: "p5" },
|
{ name: "param5", value: "p5" },
|
||||||
|
@ -47,3 +48,25 @@ describe("Filter param builder", () => {
|
||||||
expect(results).toBe("filter=param3=1:param4=2:param5=p5");
|
expect(results).toBe("filter=param3=1:param4=2:param5=p5");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Command builder", () => {
|
||||||
|
test("Defaults", () => {
|
||||||
|
expect(get(previewCommand)).toBe("ffmpeg -i punch.mp4 out.mp4");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Simple video filter", () => {
|
||||||
|
resetNodes();
|
||||||
|
addNode({ name: "filter", type: "V->V" }, "filter");
|
||||||
|
expect(get(previewCommand)).toBe(
|
||||||
|
`ffmpeg -i punch.mp4 -filter_complex "[0:v]filter[vid_out]" -map 0:a -map "[vid_out]" out.mp4`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Simple audio filter", () => {
|
||||||
|
resetNodes();
|
||||||
|
addNode({ name: "filter", type: "A->A" }, "filter");
|
||||||
|
expect(get(previewCommand)).toBe(
|
||||||
|
`ffmpeg -i punch.mp4 -filter_complex "[0:a]filter[aud_out]" -map "[aud_out]" -map 0:v out.mp4`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue