feat: add encoding profiles for DVD and BluRay quality presets
This commit is contained in:
+18
-7
@@ -1,16 +1,31 @@
|
||||
import { parsedVideoInfo } from "./types.ts";
|
||||
import { basename, dirname } from "@std/path";
|
||||
import { profile } from "./types.ts";
|
||||
|
||||
function escapeFilename(filename: string): string {
|
||||
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 {
|
||||
let videoName: string | null = null;
|
||||
const videoPath = dirname(videoInfo.filename);
|
||||
if (videoInfo.metadata) {
|
||||
videoName = videoInfo.metadata.title;
|
||||
}
|
||||
const profile = videoInfo.MPix < 1 ? profiles.DVD : profiles.BluRay;
|
||||
const args = [
|
||||
"ffmpeg \\\n",
|
||||
"-v",
|
||||
@@ -27,16 +42,12 @@ export function encodingCommandBuilder(videoInfo: parsedVideoInfo): string {
|
||||
"-pix_fmt",
|
||||
"yuv420p10le \\\n",
|
||||
];
|
||||
if (videoInfo.MPix < 1) {
|
||||
args.push("-crf", "29 \\\n");
|
||||
} else {
|
||||
args.push("-crf", "25 \\\n");
|
||||
}
|
||||
args.push("-crf", profile.crf + " \\\n");
|
||||
args.push(
|
||||
"-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) {
|
||||
const filter_string: string[] = [];
|
||||
|
||||
@@ -224,3 +224,9 @@ export interface parsedVideoInfo {
|
||||
audioStreams?: parsedAudioStream[];
|
||||
subtitleStreams?: parsedSubtitleStream[];
|
||||
}
|
||||
|
||||
export interface profile {
|
||||
crf: number;
|
||||
preset: number;
|
||||
filmGrain: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user