feat: add encoding profiles for DVD and BluRay quality presets

This commit is contained in:
Esa Kataja
2025-08-23 00:04:01 +03:00
parent 4631524510
commit 477718cb34
2 changed files with 24 additions and 7 deletions
+18 -7
View File
@@ -1,16 +1,31 @@
import { parsedVideoInfo } from "./types.ts"; import { parsedVideoInfo } from "./types.ts";
import { basename, dirname } from "@std/path"; import { basename, dirname } from "@std/path";
import { profile } from "./types.ts";
function escapeFilename(filename: string): string { function escapeFilename(filename: string): string {
return filename.replace(/[^a-zA-Z0-9]/g, ""); return filename.replace(/[^a-zA-Z0-9]/g, "");
} }
const profiles: Record<string, profile> = {
"DVD": {
"crf": 29,
"preset": 2,
"filmGrain": 5,
},
"BluRay": {
"crf": 27,
"preset": 2,
"filmGrain": 5,
},
};
export function encodingCommandBuilder(videoInfo: parsedVideoInfo): string { export function encodingCommandBuilder(videoInfo: parsedVideoInfo): string {
let videoName: string | null = null; let videoName: string | null = null;
const videoPath = dirname(videoInfo.filename); const videoPath = dirname(videoInfo.filename);
if (videoInfo.metadata) { if (videoInfo.metadata) {
videoName = videoInfo.metadata.title; videoName = videoInfo.metadata.title;
} }
const profile = videoInfo.MPix < 1 ? profiles.DVD : profiles.BluRay;
const args = [ const args = [
"ffmpeg \\\n", "ffmpeg \\\n",
"-v", "-v",
@@ -27,16 +42,12 @@ export function encodingCommandBuilder(videoInfo: parsedVideoInfo): string {
"-pix_fmt", "-pix_fmt",
"yuv420p10le \\\n", "yuv420p10le \\\n",
]; ];
if (videoInfo.MPix < 1) { args.push("-crf", profile.crf + " \\\n");
args.push("-crf", "29 \\\n");
} else {
args.push("-crf", "25 \\\n");
}
args.push( args.push(
"-svtav1-params", "-svtav1-params",
"tune=0:film-grain=5:scd=1:film-grain-denoise=1 \\\n", `tune=0:film-grain=${profile.filmGrain}:scd=1:film-grain-denoise=1 \\\n`,
); );
args.push("-preset", "2 \\\n"); args.push("-preset", profile.preset + " \\\n");
if (videoInfo.isAnamorphic || videoInfo.isInterlaced) { if (videoInfo.isAnamorphic || videoInfo.isInterlaced) {
const filter_string: string[] = []; const filter_string: string[] = [];
+6
View File
@@ -224,3 +224,9 @@ export interface parsedVideoInfo {
audioStreams?: parsedAudioStream[]; audioStreams?: parsedAudioStream[];
subtitleStreams?: parsedSubtitleStream[]; subtitleStreams?: parsedSubtitleStream[];
} }
export interface profile {
crf: number;
preset: number;
filmGrain: number;
}