Skip to content

armgit / VERT

Public Imported from GitHub
0

The next-generation file converter. Open source, fully local* and free forever.

feat: clean up settings

JovannMC38f448d8d5eb
diff --git a/messages/en.json b/messages/en.json
index 63105d8..c8946df 100644
--- a/messages/en.json
+++ b/messages/en.json
@@ -98,8 +98,18 @@
"none": "No settings available for this format.",
"converter": "Converter",
"image": {
- "quality": "Quality",
- "depth": "Color depth",
+ "resolution": {
+ "label": "Resolution",
+ "placeholder": "e.g. 1920x1080, 1280x720"
+ },
+ "quality": {
+ "label": "Quality (%)",
+ "placeholder": "e.g. 75, 90, 100"
+ },
+ "depth": {
+ "label": "Colour depth (bits)",
+ "placeholder": "e.g. 8, 16, 32"
+ },
"color_space": "Color space",
"transparency": "Transparency",
"single_size": "Single size image"
@@ -107,19 +117,15 @@
"audio": {
"bitrate": {
"label": "Bitrate (kbps)",
- "placeholder": "Custom bitrate"
+ "placeholder": "e.g. 128, 192, 320"
},
"sample_rate": {
"label": "Sample rate (Hz)",
- "placeholder": "Custom sample rate"
+ "placeholder": "e.g. 44100, 48000"
},
"channels": {
"label": "Audio channels",
- "placeholder": "Custom audio channels"
- },
- "tracks": {
- "label": "Audio tracks",
- "placeholder": "Custom audio tracks"
+ "placeholder": "e.g. 1 (mono), 2 (stereo)"
}
},
"video": {
@@ -137,24 +143,29 @@
},
"fps": {
"label": "Frame rate (FPS)",
- "placeholder": "Custom frame rate"
+ "placeholder": "e.g. 24, 30, 60"
},
"resolution": {
"label": "Resolution",
- "placeholder": "Custom resolution"
+ "placeholder": "e.g. 1920x1080, 1280x720"
},
"bitrate": {
"video": "Video bitrate (kbps)",
"audio": "Audio bitrate (kbps)",
- "placeholder": "Custom bitrate"
+ "video_placeholder": "e.g. 1000, 2000, 4000",
+ "audio_placeholder": "e.g. 128, 192, 320"
},
"sample_rate": {
"label": "Audio sample rate (Hz)",
- "placeholder": "Custom sample rate"
+ "placeholder": "e.g. 44100, 48000"
},
"codec": {
"video": "Video codec",
"audio": "Audio codec"
+ },
+ "audioChannels": {
+ "label": "Audio channels",
+ "placeholder": "e.g. 1 (mono), 2 (stereo)"
}
},
"document": {
@@ -416,7 +427,7 @@
"file_too_large": "This file exceeds the {limit}GB browser / device limit. Try Firefox or Safari to convert this large file, which typically have higher limits."
},
"warnings": {
- "settings_change": "Changed the setting '{setting}' from '{oldValue}' to '{newValue}' for {file} to prevent conversion failure."
+ "settings_change": "Changed setting '{setting}' from '{oldValue}' to '{newValue}' for {file} ({to}) to prevent conversion failure."
}
},
"privacy": {
diff --git a/src/lib/components/functional/popups/SettingsModal.svelte b/src/lib/components/functional/popups/SettingsModal.svelte
index e30c5de..8f2b182 100644
--- a/src/lib/components/functional/popups/SettingsModal.svelte
+++ b/src/lib/components/functional/popups/SettingsModal.svelte
@@ -197,35 +197,6 @@
)}
disabled={setting.disabled}
/>
- {#if setting.hasCustomInput}
- {@const disabled =
- (settings[setting.key] ??
- targetFile
- .conversionSettings[
- setting.key
- ]) !== "custom"}
- <FancyInput
- type="text"
- value={settings[
- setting.customInputKey!
- ] ??
- targetFile
- .conversionSettings[
- setting
- .customInputKey!
- ] ??
- ""}
- placeholder={setting.placeholder}
- disabled={disabled ||
- setting.disabled}
- oninput={(e: any) =>
- handleSettingChange(
- setting.customInputKey!,
- e.currentTarget
- .value,
- )}
- />
- {/if}
{:else if setting.type === "boolean"}
<FancyInput
type="checkbox"
diff --git a/src/lib/converters/converter.svelte.ts b/src/lib/converters/converter.svelte.ts
index 9c2cd90..38f4533 100644
--- a/src/lib/converters/converter.svelte.ts
+++ b/src/lib/converters/converter.svelte.ts
@@ -8,11 +8,7 @@ import type {
} from "$lib/types/conversion-settings";
export type WorkerStatus =
- | "not-ready"
- | "downloading"
- | "ready"
- | "partially-ready"
- | "error";
+ "not-ready" | "downloading" | "ready" | "partially-ready" | "error";
export class FormatInfo {
public name: string;
diff --git a/src/lib/converters/ffmpeg/ffmpeg.svelte.ts b/src/lib/converters/ffmpeg/ffmpeg.svelte.ts
index 6be159b..726b505 100644
--- a/src/lib/converters/ffmpeg/ffmpeg.svelte.ts
+++ b/src/lib/converters/ffmpeg/ffmpeg.svelte.ts
@@ -124,54 +124,33 @@ export class FFmpegConverter extends Converter {
const bitrate: SettingDefinition = {
key: "bitrate",
label: m["convert.settings.audio.bitrate.label"](),
- type: "select",
- default: global.ffmpegQuality,
- options: CONVERSION_BITRATES.map((b) => ({
- value: b,
- label:
- b === "auto" || b === "custom"
- ? m[`convert.settings.common.${b}`]()
- : `${b} kbps`,
- })),
- hasCustomInput: true,
- customInputKey: "customBitrate",
+ type: "string",
+ default:
+ global.ffmpegQuality === "auto"
+ ? ""
+ : global.ffmpegQuality === "custom"
+ ? ""
+ : global.ffmpegQuality,
placeholder: m["convert.settings.audio.bitrate.placeholder"](),
};
const sampleRate: SettingDefinition = {
key: "sampleRate",
label: m["convert.settings.audio.sample_rate.label"](),
- type: "select",
+ type: "string",
default:
- global.ffmpegSampleRate === "custom"
- ? global.ffmpegCustomSampleRate
- : global.ffmpegSampleRate,
- options: SAMPLE_RATES.map((r) => ({
- value: r,
- label:
- r === "auto" || r === "custom"
- ? m[`convert.settings.common.${r}`]()
- : `${r} Hz`,
- })),
- hasCustomInput: true,
- customInputKey: "customSampleRate",
+ global.ffmpegSampleRate === "auto"
+ ? ""
+ : global.ffmpegSampleRate === "custom"
+ ? global.ffmpegCustomSampleRate
+ : global.ffmpegSampleRate,
placeholder: m["convert.settings.audio.sample_rate.placeholder"](),
};
- const tracks: SettingDefinition = {
- key: "tracks",
- label: m["convert.settings.audio.tracks.label"](),
- type: "number",
- default: 1,
- min: 1,
- placeholder: m["convert.settings.audio.tracks.placeholder"](),
- };
-
const channels: SettingDefinition = {
key: "channels",
label: m["convert.settings.audio.channels.label"](),
type: "number",
- default: 2,
min: 1,
max: 8,
placeholder: m["convert.settings.audio.channels.placeholder"](),
@@ -189,7 +168,7 @@ export class FFmpegConverter extends Converter {
// resize, crop, rotate - prob want a ui
- return [bitrate, sampleRate, tracks, channels, metadata];
+ return [bitrate, sampleRate, channels, metadata];
}
public async getDefaultSettings(): Promise<ConversionSettings> {
@@ -227,11 +206,7 @@ export class FFmpegConverter extends Converter {
// no idea why its broken like this in the browser only lol
if (normalized.channels >= 2) change("channels", 1);
- const bitrate = Number(
- normalized.bitrate === "custom"
- ? normalized.customBitrate
- : normalized.bitrate,
- );
+ const bitrate = Number(normalized.bitrate);
if (Number.isFinite(bitrate) && bitrate > 256)
change("bitrate", 256);
} else if (to === ".amv") {
@@ -239,11 +214,7 @@ export class FFmpegConverter extends Converter {
change("channels", 1);
change("bitrate", 32);
} else if (to === ".mpg" || to === ".mpeg" || to === ".vob") {
- const bitrate = Number(
- normalized.bitrate === "custom"
- ? normalized.customBitrate
- : normalized.bitrate,
- );
+ const bitrate = Number(normalized.bitrate);
if (Number.isFinite(bitrate) && bitrate > 0)
change("bitrate", Math.pow(2, Math.round(Math.log2(bitrate))));
} else if (to === ".gxf") {
@@ -284,10 +255,7 @@ export class FFmpegConverter extends Converter {
msg.includes("Specified sample rate") &&
msg.includes("is not supported")
) {
- const rate =
- conversionSettings.sampleRate === "custom"
- ? conversionSettings.customSampleRate
- : conversionSettings.sampleRate;
+ const rate = conversionSettings.sampleRate;
conversionError = m["workers.errors.invalid_rate"]({
rate,
});
@@ -426,9 +394,7 @@ export class FFmpegConverter extends Converter {
const isImageSequence = input.isZip() && settings.imageSequence;
const userBitrate = settings.bitrate;
- const customBitrate = settings.customBitrate;
const userSampleRate = settings.sampleRate;
- const customSampleRate = settings.customSampleRate;
const keepMetadata = settings.metadata;
// image sequences -> animated image // video
@@ -482,7 +448,6 @@ export class FFmpegConverter extends Converter {
let audioBitrateArgs: string[] = [];
let sampleRateArgs: string[] = [];
let channelsArgs: string[] = [];
- let tracksArgs: string[] = [];
let metadataArgs: string[] = [];
const extraArgs: string[] = [];
if (to === ".amv") {
@@ -509,12 +474,9 @@ export class FFmpegConverter extends Converter {
const isLosslessToLossy =
lossless.includes(inputFormat) && !lossless.includes(outputFormat);
- if (userBitrate !== "auto") {
+ if (userBitrate) {
// user's setting
- audioBitrateArgs = [
- "-b:a",
- `${userBitrate === "custom" ? customBitrate : userBitrate}k`,
- ];
+ audioBitrateArgs = ["-b:a", `${userBitrate}k`];
this.log(`using user setting for audio bitrate: ${userBitrate}`);
} else {
// detect bitrate of original file and use
@@ -548,15 +510,8 @@ export class FFmpegConverter extends Converter {
}
// sample rate setting
- if (userSampleRate !== "auto") {
- sampleRateArgs = [
- "-ar",
- String(
- userSampleRate === "custom"
- ? customSampleRate
- : userSampleRate,
- ),
- ];
+ if (userSampleRate) {
+ sampleRateArgs = ["-ar", String(userSampleRate)];
this.log(`using user setting for sample rate: ${userSampleRate}Hz`);
} else {
// detect sample rate of original file and use
@@ -595,21 +550,6 @@ export class FFmpegConverter extends Converter {
);
}
- // tracks setting
- // TODO: select specific tracks? (prob should be for the other settings that need extra ui stuff)
- if (settings.tracks !== "auto") {
- // -map for each audio track
- if (settings.tracks > 1) {
- for (let i = 0; i < settings.tracks; i++) {
- tracksArgs.push("-map", `0:a:${i}`);
- }
- } else {
- tracksArgs = ["-map", "0:a:0"]; // default to first audio track if not specified
- }
-
- this.log(`using user setting for audio tracks: ${settings.tracks}`);
- }
-
// video to audio
if (videoFormats.includes(inputFormat)) {
this.log(`Converting video ${input.from} to audio ${to}`);
@@ -622,7 +562,6 @@ export class FFmpegConverter extends Converter {
...audioBitrateArgs,
...sampleRateArgs,
...channelsArgs,
- ...tracksArgs,
...extraArgs,
"output" + to,
];
@@ -676,7 +615,6 @@ export class FFmpegConverter extends Converter {
...audioBitrateArgs,
...sampleRateArgs,
...channelsArgs,
- ...tracksArgs,
...extraArgs,
"-strict",
"experimental",
@@ -705,10 +643,7 @@ const handleSpecialOutput = async (
conversionSettings.sampleRate &&
conversionSettings.sampleRate !== "auto"
) {
- sampleRate =
- conversionSettings.sampleRate === "custom"
- ? (conversionSettings.customSampleRate as number)
- : (conversionSettings.sampleRate as number);
+ sampleRate = conversionSettings.sampleRate as number;
} else {
const args = [
"-v",
diff --git a/src/lib/converters/magick/magick.svelte.ts b/src/lib/converters/magick/magick.svelte.ts
index a65836d..84d3bd0 100644
--- a/src/lib/converters/magick/magick.svelte.ts
+++ b/src/lib/converters/magick/magick.svelte.ts
@@ -155,68 +155,22 @@ export class MagickConverter extends Converter {
break;
}
- const toRes = (
- w: number,
- h?: number,
- ): { value: string; label: string } => {
- if (w && h) {
- if (w < h)
- return { value: `${w}x${h}`, label: `${w}x${h} (V)` };
- if (w > h) return { value: `${w}x${h}`, label: `${w}x${h}` };
- return { value: `${w}x${h}`, label: `${w}x${h}` };
- }
- if (w) return { value: `${w}x${w}`, label: `${w}x${w}` };
- return { value: "", label: "" };
- };
-
const quality: SettingDefinition = {
key: "quality",
- label: m["convert.settings.image.quality"](),
+ label: m["convert.settings.image.quality.label"](),
type: "number",
- default: global.magickQuality ?? 100,
min: 0,
max: 100,
+ placeholder: m["convert.settings.image.quality.placeholder"](),
};
settings.push(quality);
- // TODO: surely there's a better way to do this as well
- const iconResolutions = [
- toRes(16),
- toRes(32),
- toRes(48),
- toRes(64),
- toRes(128),
- toRes(256),
- toRes(512),
- ];
- const commonResolutions = [
- {
- value: "custom",
- label: m["convert.settings.common.custom"](),
- },
- toRes(320, 240),
- toRes(426, 240),
- toRes(640, 360),
- toRes(854, 480),
- toRes(720, 1280),
- toRes(1280, 720),
- toRes(1080, 1920),
- toRes(1920, 1080),
- toRes(2160, 3840),
- toRes(3840, 2160),
- ];
const resolution: SettingDefinition = {
key: "resolution",
- label: m["convert.settings.video.resolution.label"](),
- type: "select",
- default: "auto",
- options: [
- { value: "auto", label: m["convert.settings.common.auto"]() },
- ...(toIcon ? iconResolutions : commonResolutions),
- ],
- hasCustomInput: true,
- customInputKey: "customResolution",
- placeholder: m["convert.settings.video.resolution.placeholder"](),
+ label: m["convert.settings.image.resolution.label"](),
+ type: "string",
+ default: "",
+ placeholder: m["convert.settings.image.resolution.placeholder"](),
};
settings.push(resolution);
@@ -230,16 +184,10 @@ export class MagickConverter extends Converter {
const depth: SettingDefinition = {
key: "depth",
- label: m["convert.settings.image.depth"](),
- type: "select",
- default: "auto",
- options: [
- { value: "auto", label: "Auto" },
- // { value: "custom", label: "Custom" },
- { value: "8", label: "8-bit" },
- { value: "16", label: "16-bit" },
- { value: "32", label: "32-bit" },
- ],
+ label: m["convert.settings.image.depth.label"](),
+ type: "string",
+ default: "",
+ placeholder: m["convert.settings.image.depth.placeholder"](),
};
settings.push(depth);
@@ -468,18 +416,10 @@ export class MagickConverter extends Converter {
const defaultSize = 512;
let [width, height] = [defaultSize, defaultSize];
- // TODO: figure out a better way to process "custom" settings in general lol (see vertd.svelte.ts#processSettings)
if (settings.resolution) {
- const resolution =
- settings.resolution === "custom"
- ? settings.customResolution
- : settings.resolution;
- [width, height] = resolution
+ [width, height] = settings.resolution
.split("x")
.map((dim: string) => parseInt(dim));
- this.log(
- `using custom dimensions from settings for SVG: ${width}x${height}`,
- );
} else {
const widthMatch = svgText.match(/width=["'](\d+)["']/);
const heightMatch = svgText.match(/height=["'](\d+)["']/);
diff --git a/src/lib/converters/mediabunny/mediabunny.svelte.ts b/src/lib/converters/mediabunny/mediabunny.svelte.ts
index dd9da9d..42949ea 100644
--- a/src/lib/converters/mediabunny/mediabunny.svelte.ts
+++ b/src/lib/converters/mediabunny/mediabunny.svelte.ts
@@ -121,26 +121,16 @@ const buildVideoConfig = (
if (settings.videoCodec !== "auto") config.codec = settings.videoCodec;
- if (settings.videoBitrate !== "auto") {
- const bitrate =
- settings.videoBitrate === "custom"
- ? settings.customVideoBitrate
- : settings.videoBitrate;
- config.bitrate = Number(bitrate);
+ if (settings.videoBitrate && settings.videoBitrate !== "auto") {
+ config.bitrate = Number(settings.videoBitrate);
}
- if (settings.fps !== "auto") {
- const fps =
- settings.fps === "custom" ? settings.customFps : settings.fps;
- config.frameRate = Number(fps);
+ if (settings.fps && settings.fps !== "auto") {
+ config.frameRate = Number(settings.fps);
}
- if (settings.resolution !== "auto") {
- const resolution =
- settings.resolution === "custom"
- ? settings.customResolution
- : settings.resolution;
- const [width, height] = resolution.split("x").map(Number);
+ if (settings.resolution && settings.resolution !== "auto") {
+ const [width, height] = settings.resolution.split("x").map(Number);
config.width = width;
config.height = height;
config.fit = "contain"; // TODO: maybe allow changing this?
@@ -156,20 +146,12 @@ const buildAudioConfig = (
if (settings.audioCodec !== "auto") config.codec = settings.audioCodec;
- if (settings.audioBitrate !== "auto") {
- const bitrate =
- settings.audioBitrate === "custom"
- ? settings.customAudioBitrate
- : settings.audioBitrate;
- config.bitrate = Number(bitrate);
+ if (settings.audioBitrate && settings.audioBitrate !== "auto") {
+ config.bitrate = Number(settings.audioBitrate);
}
- if (settings.sampleRate !== "auto") {
- const sampleRate =
- settings.sampleRate === "custom"
- ? settings.customSampleRate
- : settings.sampleRate;
- config.sampleRate = Number(sampleRate);
+ if (settings.sampleRate && settings.sampleRate !== "auto") {
+ config.sampleRate = Number(settings.sampleRate);
}
return config;
@@ -282,49 +264,16 @@ export class MediabunnyConverter extends Converter {
const fps: SettingDefinition = {
key: "fps",
label: m["convert.settings.video.fps.label"](),
- type: "select",
- default: "auto",
- options: [
- { value: "auto", label: m["convert.settings.common.auto"]() },
- {
- value: "custom",
- label: m["convert.settings.common.custom"](),
- },
- { value: "24", label: "24" },
- { value: "30", label: "30" },
- { value: "60", label: "60" },
- { value: "120", label: "120" },
- { value: "144", label: "144" },
- { value: "240", label: "240" },
- ],
- hasCustomInput: true,
- customInputKey: "customFps",
+ type: "string",
+ default: "",
placeholder: m["convert.settings.video.fps.placeholder"](),
};
const resolution: SettingDefinition = {
key: "resolution",
label: m["convert.settings.video.resolution.label"](),
- type: "select",
- default: "auto",
- options: [
- { value: "auto", label: m["convert.settings.common.auto"]() },
- {
- value: "custom",
- label: m["convert.settings.common.custom"](),
- },
- { value: "426x240", label: "426x240" },
- { value: "640x360", label: "640x360" },
- { value: "854x480", label: "854x480" },
- { value: "720x1280", label: "720x1280 (V)" },
- { value: "1280x720", label: "1280x720" },
- { value: "1080x1920", label: "1080x1920 (V)" },
- { value: "1920x1080", label: "1920x1080" },
- { value: "2160x3840", label: "2160x3840 (V)" },
- { value: "3840x2160", label: "3840x2160" },
- ],
- hasCustomInput: true,
- customInputKey: "customResolution",
+ type: "string",
+ default: "",
placeholder: m["convert.settings.video.resolution.placeholder"](),
};
@@ -332,24 +281,10 @@ export class MediabunnyConverter extends Converter {
const videoBitrate: SettingDefinition = {
key: "videoBitrate",
label: m["convert.settings.video.bitrate.video"](),
- type: "select",
- default: "auto",
- options: [
- { value: "auto", label: m["convert.settings.common.auto"]() },
- {
- value: "custom",
- label: m["convert.settings.common.custom"](),
- },
- { value: "1000", label: "1000 kbps" },
- { value: "2500", label: "2500 kbps" },
- { value: "5000", label: "5000 kbps" },
- { value: "8000", label: "8000 kbps" },
- { value: "12000", label: "12000 kbps" },
- { value: "18000", label: "18000 kbps" },
- ],
- hasCustomInput: true,
- customInputKey: "customVideoBitrate",
- placeholder: m["convert.settings.video.bitrate.placeholder"](),
+ type: "string",
+ default: "",
+ placeholder:
+ m["convert.settings.video.bitrate.video_placeholder"](),
};
const toFormat = input.to;
@@ -389,38 +324,17 @@ export class MediabunnyConverter extends Converter {
const audioBitrate: SettingDefinition = {
key: "audioBitrate",
label: m["convert.settings.video.bitrate.audio"](),
- type: "select",
- default: "auto",
- options: CONVERSION_BITRATES.map((b) => ({
- value: b.toString(),
- label:
- b === "auto"
- ? m["convert.settings.common.auto"]()
- : b === "custom"
- ? m["convert.settings.common.custom"]()
- : `${b} kbps`,
- })),
- hasCustomInput: true,
- customInputKey: "customAudioBitrate",
- placeholder: m["convert.settings.audio.bitrate.placeholder"](),
+ type: "string",
+ default: "",
+ placeholder:
+ m["convert.settings.video.bitrate.audio_placeholder"](),
};
const sampleRate: SettingDefinition = {
key: "sampleRate",
label: m["convert.settings.audio.sample_rate.label"](),
- type: "select",
- default: "auto",
- options: SAMPLE_RATES.map((r) => ({
- value: r.toString(),
- label:
- r === "auto"
- ? m["convert.settings.common.auto"]()
- : r === "custom"
- ? m["convert.settings.common.custom"]()
- : `${r} Hz`,
- })),
- hasCustomInput: true,
- customInputKey: "customSampleRate",
+ type: "string",
+ default: "",
placeholder: m["convert.settings.audio.sample_rate.placeholder"](),
};
diff --git a/src/lib/converters/vertd/vertd.svelte.ts b/src/lib/converters/vertd/vertd.svelte.ts
index ca7eac3..46e2ec5 100644
--- a/src/lib/converters/vertd/vertd.svelte.ts
+++ b/src/lib/converters/vertd/vertd.svelte.ts
@@ -114,12 +114,7 @@ export const vertdFetch: {
// ws types
export type ConversionSpeed =
- | "verySlow"
- | "slower"
- | "slow"
- | "medium"
- | "fast"
- | "ultraFast";
+ "verySlow" | "slower" | "slow" | "medium" | "fast" | "ultraFast";
const vertdSpeedValues: ConversionSpeed[] = [
"verySlow",
@@ -143,7 +138,7 @@ interface StartJobMessage {
interface ErrorMessage {
type: "error";
data: {
- message: string;
+ message: unknown;
};
}
@@ -218,31 +213,16 @@ const progressEstimate = (
return progress * progressEstimates[type] + previousValues;
};
-const processSettings = (settings: ConversionSettings): ConversionSettings => {
- const newSettings = { ...settings };
+const formatError = (message: unknown): string => {
+ if (typeof message === "string") return message;
+ if (message instanceof Error) return message.message;
+ if (message === undefined) return "Unknown Vertd error";
- if (newSettings.fps === "custom") {
- newSettings.fps = newSettings.customFps;
- delete newSettings.customFps;
- }
- if (newSettings.resolution === "custom") {
- newSettings.resolution = newSettings.customResolution;
- delete newSettings.customResolution;
- }
- if (newSettings.videoBitrate === "custom") {
- newSettings.videoBitrate = newSettings.customVideoBitrate;
- delete newSettings.customVideoBitrate;
- }
- if (newSettings.audioBitrate === "custom") {
- newSettings.audioBitrate = newSettings.customAudioBitrate;
- delete newSettings.customAudioBitrate;
- }
- if (newSettings.sampleRate === "custom") {
- newSettings.sampleRate = newSettings.customSampleRate;
- delete newSettings.customSampleRate;
+ try {
+ return JSON.stringify(message);
+ } catch {
+ return String(message);
}
-
- return newSettings;
};
interface UploadTask {
@@ -555,49 +535,16 @@ export class VertdConverter extends Converter {
const fps: SettingDefinition = {
key: "fps",
label: m["convert.settings.video.fps.label"](),
- type: "select",
- default: "auto",
- options: [
- { value: "auto", label: m["convert.settings.common.auto"]() },
- {
- value: "custom",
- label: m["convert.settings.common.custom"](),
- },
- { value: "24", label: "24" },
- { value: "30", label: "30" },
- { value: "60", label: "60" },
- { value: "120", label: "120" },
- { value: "144", label: "144" },
- { value: "240", label: "240" },
- ],
- hasCustomInput: true,
- customInputKey: "customFps",
+ type: "string",
+ default: "",
placeholder: m["convert.settings.video.fps.placeholder"](),
};
const resolution: SettingDefinition = {
key: "resolution",
label: m["convert.settings.video.resolution.label"](),
- type: "select",
- default: "auto",
- options: [
- { value: "auto", label: m["convert.settings.common.auto"]() },
- {
- value: "custom",
- label: m["convert.settings.common.custom"](),
- },
- { value: "426x240", label: "426x240" },
- { value: "640x360", label: "640x360" },
- { value: "854x480", label: "854x480" },
- { value: "720x1280", label: "720x1280 (V)" },
- { value: "1280x720", label: "1280x720" },
- { value: "1080x1920", label: "1080x1920 (V)" },
- { value: "1920x1080", label: "1920x1080" },
- { value: "2160x3840", label: "2160x3840 (V)" },
- { value: "3840x2160", label: "3840x2160" },
- ],
- hasCustomInput: true,
- customInputKey: "customResolution",
+ type: "string",
+ default: "",
placeholder: m["convert.settings.video.resolution.placeholder"](),
};
@@ -619,24 +566,10 @@ export class VertdConverter extends Converter {
const videoBitrate: SettingDefinition = {
key: "videoBitrate",
label: m["convert.settings.video.bitrate.video"](),
- type: "select",
- default: "auto",
- options: [
- { value: "auto", label: m["convert.settings.common.auto"]() },
- {
- value: "custom",
- label: m["convert.settings.common.custom"](),
- },
- { value: "1000", label: "1000 kbps" },
- { value: "2500", label: "2500 kbps" },
- { value: "5000", label: "5000 kbps" },
- { value: "8000", label: "8000 kbps" },
- { value: "12000", label: "12000 kbps" },
- { value: "18000", label: "18000 kbps" },
- ],
- hasCustomInput: true,
- customInputKey: "customVideoBitrate",
- placeholder: m["convert.settings.video.bitrate.placeholder"](),
+ type: "string",
+ default: "",
+ placeholder:
+ m["convert.settings.video.bitrate.video_placeholder"](),
};
/*
@@ -659,41 +592,30 @@ export class VertdConverter extends Converter {
const audioBitrate: SettingDefinition = {
key: "audioBitrate",
label: m["convert.settings.video.bitrate.audio"](),
- type: "select",
- default: "auto",
- options: CONVERSION_BITRATES.map((b) => ({
- value: b.toString(),
- label:
- b === "auto"
- ? m["convert.settings.common.auto"]()
- : b === "custom"
- ? m["convert.settings.common.custom"]()
- : `${b} kbps`,
- })),
- hasCustomInput: true,
- customInputKey: "customAudioBitrate",
- placeholder: m["convert.settings.audio.bitrate.placeholder"](),
+ type: "string",
+ default: "",
+ placeholder:
+ m["convert.settings.video.bitrate.audio_placeholder"](),
};
const sampleRate: SettingDefinition = {
key: "sampleRate",
label: m["convert.settings.audio.sample_rate.label"](),
- type: "select",
- default: "auto",
- options: SAMPLE_RATES.map((r) => ({
- value: r.toString(),
- label:
- r === "auto"
- ? m["convert.settings.common.auto"]()
- : r === "custom"
- ? m["convert.settings.common.custom"]()
- : `${r} Hz`,
- })),
- hasCustomInput: true,
- customInputKey: "customSampleRate",
+ type: "string",
+ default: "",
placeholder: m["convert.settings.audio.sample_rate.placeholder"](),
};
+ const audioChannels: SettingDefinition = {
+ key: "audioChannels",
+ label: m["convert.settings.video.audioChannels.label"](),
+ type: "number",
+ min: 1,
+ max: 8,
+ placeholder:
+ m["convert.settings.video.audioChannels.placeholder"](),
+ };
+
/*
* common
*/
@@ -717,6 +639,7 @@ export class VertdConverter extends Converter {
videoBitrate,
audioBitrate,
fps,
+ audioChannels,
sampleRate,
resolution,
metadata,
@@ -757,9 +680,18 @@ export class VertdConverter extends Converter {
});
};
- if (to === ".mxf") {
- change("sampleRate", "48000");
- }
+ // handled in backend now
+ // if (to === ".mxf") {
+ // change("sampleRate", "48000");
+ // }
+
+ // // gxf was used for tv program systems/archives, so only PAL/NTSC resolutions
+ // if (to === ".gxf") {
+ // // for now, just PAL cause highest res at 720x576
+ // change("resolution", "720x576");
+ // change("sampleRate", "48000");
+ // change("audioChannels", "1");
+ // }
return { settings: normalized, changes };
}
@@ -882,7 +814,7 @@ export class VertdConverter extends Converter {
jobId: uploadRes.id,
token: uploadRes.auth,
to,
- settings: processSettings(conversionSettings),
+ settings: conversionSettings,
},
};
ws.send(JSON.stringify(msg));
@@ -991,7 +923,8 @@ export class VertdConverter extends Converter {
}
case "error": {
- this.error(`error: ${msg.data.message}`);
+ const errorMessage = formatError(msg.data.message);
+ this.error(`error: ${errorMessage}`);
if (hash) this.failure(hash);
rejectConversion({
@@ -1001,7 +934,7 @@ export class VertdConverter extends Converter {
auth: uploadRes.auth,
from: input.from,
to: to,
- errorMessage: msg.data.message,
+ errorMessage,
},
});
break;
diff --git a/src/lib/sections/settings/vertdSettings.svelte.ts b/src/lib/sections/settings/vertdSettings.svelte.ts
index 1f660d7..c8819f5 100644
--- a/src/lib/sections/settings/vertdSettings.svelte.ts
+++ b/src/lib/sections/settings/vertdSettings.svelte.ts
@@ -8,10 +8,7 @@ const LOCATIONS = [
];
export type VertdInner =
- | { type: "auto" }
- | { type: "eu" }
- | { type: "us" }
- | { type: "custom" };
+ { type: "auto" } | { type: "eu" } | { type: "us" } | { type: "custom" };
export const getVertdCustomHeaders = (): Record<string, string> => {
const raw = Settings.instance.settings.vertdCustomHeaders.trim();
diff --git a/src/lib/store/index.svelte.ts b/src/lib/store/index.svelte.ts
index f7b9f97..ef7a0ff 100644
--- a/src/lib/store/index.svelte.ts
+++ b/src/lib/store/index.svelte.ts
@@ -377,13 +377,7 @@ class Files {
public add(file: FileList | null | undefined): void;
public add(
file:
- | VertFile
- | File
- | VertFile[]
- | File[]
- | FileList
- | null
- | undefined,
+ VertFile | File | VertFile[] | File[] | FileList | null | undefined,
) {
if (!file) return;
if (Array.isArray(file) || file instanceof FileList) {
diff --git a/src/lib/types/conversion-settings.ts b/src/lib/types/conversion-settings.ts
index 3e3d38f..5c523b8 100644
--- a/src/lib/types/conversion-settings.ts
+++ b/src/lib/types/conversion-settings.ts
@@ -13,8 +13,6 @@ export interface SettingDefinition {
step?: number;
options?: Array<{ value: any; label: any }>; // for select/range types
description?: string;
- hasCustomInput?: boolean; // for select types with a "custom" option
- customInputKey?: string; // key to use for custom input value in settings object
forceFullWidth?: boolean; // force setting to take up full width (usually grid 2)
}
diff --git a/src/lib/util/toast.svelte.ts b/src/lib/util/toast.svelte.ts
index a7e3d75..a860228 100644
--- a/src/lib/util/toast.svelte.ts
+++ b/src/lib/util/toast.svelte.ts
@@ -82,8 +82,7 @@ export type ComponentToastOptions<T> = BaseToastOptions & {
};
export type ToastOptions<T = unknown> =
- | StringToastOptions
- | ComponentToastOptions<T>;
+ StringToastOptions | ComponentToastOptions<T>;
// const toasts = writable<Toast[]>([]);
diff --git a/src/lib/workers/magick.ts b/src/lib/workers/magick.ts
index ff13634..e38e645 100644
--- a/src/lib/workers/magick.ts
+++ b/src/lib/workers/magick.ts
@@ -334,12 +334,7 @@ const magickConvert = async (
const resolution = conversionSettings.resolution as string;
if (!singleSize && resolution && resolution !== "auto") {
- const actualResolution =
- resolution === "custom"
- ? (conversionSettings.customResolution as string)
- : resolution;
-
- const [width, height] = actualResolution
+ const [width, height] = resolution
.split("x")
.map((dim: string) => parseInt(dim));
@@ -359,11 +354,7 @@ const magickConvert = async (
let desired = 0;
if (resolution && resolution !== "auto") {
- const actualResolution =
- resolution === "custom"
- ? (conversionSettings.customResolution as string)
- : resolution;
- const [wsel, hsel] = (actualResolution || "")
+ const [wsel, hsel] = (resolution || "")
.split("x")
.map((d: string) => parseInt(d) || 0);
desired = Math.max(wsel || 0, hsel || 0);