The next-generation file converter. Open source, fully local* and free forever.
Merge branch 'nullptr/experimental-audio-to-video'
JovannMC5da55a56a1a6
diff --cc src/lib/converters/ffmpeg.svelte.tsindex 5172bf8,99489b5..a4367cb--- a/src/lib/converters/ffmpeg.svelte.ts+++ b/src/lib/converters/ffmpeg.svelte.ts@@@ -11,17 -13,17 +13,18 @@@ export class FFmpegConverter extends Copublic ready = $state(false);public supportedFormats = [- new FormatInfo("mp3"),- new FormatInfo("wav"),- new FormatInfo("flac"),- new FormatInfo("ogg"),- new FormatInfo("aac"),- new FormatInfo("m4a"),+ new FormatInfo("mp3", true, true),+ new FormatInfo("wav", true, true),+ new FormatInfo("flac", true, true),+ new FormatInfo("ogg", true, true),+ new FormatInfo("aac", true, true),+ new FormatInfo("m4a", true, true),+ ...videoFormats.map((f) => new FormatInfo(f, true, true, false)),- new FormatInfo("wma"),- new FormatInfo("amr", true, false),- new FormatInfo("ac3"),- new FormatInfo("aiff"),+ new FormatInfo("wma", true, true),+ new FormatInfo("amr", true, true),+ new FormatInfo("ac3", true, true),- new FormatInfo("alac", true, false),++ new FormatInfo("alac", true, true),+ new FormatInfo("aiff", true, true),];public readonly reportsProgress = true;diff --cc src/lib/converters/index.tsindex b93f1e3,3ccb073..4b57c65--- a/src/lib/converters/index.ts+++ b/src/lib/converters/index.ts@@@ -1,4 -1,4 +1,5 @@@+import type { Categories } from "$lib/types";+ import type { Converter } from "./converter.svelte";import { FFmpegConverter } from "./ffmpeg.svelte";import { PandocConverter } from "./pandoc.svelte";import { VertdConverter } from "./vertd.svelte";@@@ -11,39 -11,14 +12,50 @@@ export const converters =new PandocConverter(),];+export function getConverterByFormat(format: string) {+ for (const converter of converters) {+ if (converter.supportedFormats.some((f) => f.name === format)) {+ return converter;+ }+ }+ return null;+}++export const categories: Categories = {+ image: { formats: [""], canConvertTo: [] },+ video: { formats: [""], canConvertTo: [] }, // add "audio" when "nullptr/experimental-audio-to-video" is implemented+ audio: { formats: [""], canConvertTo: [] }, // add "video" when "nullptr/experimental-audio-to-video" is implemented+ docs: { formats: [""], canConvertTo: [] },+};++categories.audio.formats =+ converters+ .find((c) => c.name === "ffmpeg")+ ?.formatStrings((f) => f.toSupported)+ .filter((f) => f !== "mp3") || [];+categories.video.formats =+ converters+ .find((c) => c.name === "vertd")+ ?.formatStrings((f) => f.toSupported)+ .filter((f) => f !== "mp4") || [];+categories.image.formats =+ converters+ .find((c) => c.name === "libvips")+ ?.formatStrings((f) => f.toSupported)+ .filter((f) => f !== ".webp" && f !== ".gif") || [];+categories.docs.formats =+ converters+ .find((c) => c.name === "pandoc")+ ?.formatStrings((f) => f.toSupported)+ .filter((f) => f !== ".pdf") || [];+ export const byNative = (format: string) => {+ return (a: Converter, b: Converter) => {+ const aFormat = a.supportedFormats.find((f) => f.name === format);+ const bFormat = b.supportedFormats.find((f) => f.name === format);++ if (aFormat && bFormat) {+ return aFormat.isNative ? -1 : 1;+ }+ return 0;+ };+ };diff --cc src/lib/converters/vips.svelte.tsindex 7c8ad66,c874add..ccbe324--- a/src/lib/converters/vips.svelte.ts+++ b/src/lib/converters/vips.svelte.ts@@@ -17,33 -17,32 +17,33 @@@ export class VipsConverter extends Convpublic ready = $state(false);public supportedFormats = [- new FormatInfo("png", true, true),- new FormatInfo("jpeg", true, true),- new FormatInfo("jpg", true, true),- new FormatInfo("webp", true, true),- new FormatInfo("gif", true, true),+ new FormatInfo("png"),+ new FormatInfo("jpeg"),+ new FormatInfo("jpg"),+ new FormatInfo("webp"),+ new FormatInfo("gif"),new FormatInfo("heic", true, false),new FormatInfo("ico", true, false),+ new FormatInfo("bmp", true, false),new FormatInfo("cur", true, false),new FormatInfo("ani", true, false),new FormatInfo("icns", true, false),new FormatInfo("nef", true, false),new FormatInfo("cr2", true, false),- new FormatInfo("hdr", true, true),- new FormatInfo("jpe", true, true),+ new FormatInfo("hdr"),+ new FormatInfo("jpe"),new FormatInfo("dng", true, false),- new FormatInfo("mat"),- new FormatInfo("pbm"),- new FormatInfo("pfm"),- new FormatInfo("pgm"),- new FormatInfo("pnm"),- new FormatInfo("ppm"),+ new FormatInfo("mat", true, true),+ new FormatInfo("pbm", true, true),+ new FormatInfo("pfm", true, true),+ new FormatInfo("pgm", true, true),+ new FormatInfo("pnm", true, true),+ new FormatInfo("ppm", false, true),new FormatInfo("raw", false, true),- new FormatInfo("tif", true, true),- new FormatInfo("tiff", true, true),- new FormatInfo("jfif", true, true),- new FormatInfo("avif", true, true),+ new FormatInfo("tif"),+ new FormatInfo("tiff"),+ new FormatInfo("jfif"),+ new FormatInfo("avif"),];public readonly reportsProgress = false;diff --cc src/routes/convert/+page.svelteindex 9b21bab,75d9aa8..90e37d2--- a/src/routes/convert/+page.svelte+++ b/src/routes/convert/+page.svelte@@@ -5,7 -5,7 +5,7 @@@import Panel from "$lib/components/visual/Panel.svelte";import ProgressBar from "$lib/components/visual/ProgressBar.svelte";import Tooltip from "$lib/components/visual/Tooltip.svelte";- import { categories, converters } from "$lib/converters";- import { converters, byNative } from "$lib/converters";++ import { categories, converters, byNative } from "$lib/converters";import {effects,files,