ffmpeg-explorer/src/stores.js

56 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-08-22 12:05:49 -04:00
import { v4 as uuidv4 } from "uuid";
2023-08-18 17:23:56 -04:00
import { writable } from 'svelte/store';
2023-08-22 12:05:49 -04:00
export const inputs = writable([{name: "punch.mp4", id: uuidv4()}]);
2023-08-19 13:01:37 -04:00
export const output = writable("out.mp4");
2023-08-18 17:23:56 -04:00
export const filters = writable([]);
2023-08-22 12:05:49 -04:00
export function addFilter(f) {
const newFilter = { ...f, filterId: f.id, id: uuidv4() };
if (f.params) {
newFilter.params = f.params.map((p) => {
p.value = null;
if (p.default != null) p.value = p.default;
return p;
});
}
filters.update((filts) => {
filts.push(newFilter)
return filts;
})
}
export function removeFilter(id) {
filters.update((filts) => {
const index = filts.findIndex((f) => f.id === id);
filts.splice(index, 1);
return filts;
});
}
export function addOutput(f) {
}
export function removeOutput(f) {
}
export function addInput(f) {
const newInput = {name: f, id: uuidv4()}
inputs.update((inps) => {
inps.push(newInput);
return inps;
});
}
export function removeInput(id) {
inputs.update((inps) => {
const index = inps.findIndex((f) => f.id === id);
inps.splice(index, 1);
return inps;
});
}