fix: add av1 and h26X with containers

issue: #287, #293
This commit is contained in:
C4illin
2025-05-23 21:15:36 +02:00
parent 3b573cccae
commit af5c768dc7

View File

@@ -508,7 +508,8 @@ export const properties = {
"ast", "ast",
"au", "au",
"aud", "aud",
"av1", "av1.mkv",
"av1.mp4",
"avi", "avi",
"avif", "avif",
"avs", "avs",
@@ -546,9 +547,11 @@ export const properties = {
"gxf", "gxf",
"h261", "h261",
"h263", "h263",
"h264", "h264.mkv",
"h265", "h264.mp4",
"h266", "h265.mkv",
"h265.mp4",
"h266.mkv",
"hdr", "hdr",
"hevc", "hevc",
"ico", "ico",
@@ -696,23 +699,44 @@ export async function convert(
if (convertTo === "ico") { if (convertTo === "ico") {
// make sure image is 256x256 or smaller // make sure image is 256x256 or smaller
extraArgs = ['-filter:v', "scale='min(256,iw)':min'(256,ih)':force_original_aspect_ratio=decrease"]; extraArgs = [
"-filter:v",
"scale='min(256,iw)':min'(256,ih)':force_original_aspect_ratio=decrease",
];
message = "Done: resized to 256x256"; message = "Done: resized to 256x256";
} }
// Parse FFMPEG_ARGS environment variable into array if (convertTo.split(".").length > 1) {
const ffmpegArgs = process.env.FFMPEG_ARGS ? process.env.FFMPEG_ARGS.split(/\s+/) : []; // support av1.mkv and av1.mp4 and h265.mp4 etc.
const split = convertTo.split(".");
const codec_short = split[0];
// Build arguments array switch (codec_short) {
const args = [ case "av1":
...ffmpegArgs, extraArgs.push("-c:v", "libaom-av1");
"-i", filePath, break;
...extraArgs, case "h264":
targetPath extraArgs.push("-c:v", "libx264");
]; break;
case "h265":
extraArgs.push("-c:v", "libx265");
break;
case "h266":
extraArgs.push("-c:v", "libx266");
break;
}
}
// Parse FFMPEG_ARGS environment variable into array
const ffmpegArgs = process.env.FFMPEG_ARGS
? process.env.FFMPEG_ARGS.split(/\s+/)
: [];
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
execFile("ffmpeg", args, (error, stdout, stderr) => { execFile(
"ffmpeg",
[...ffmpegArgs, "-i", filePath, ...extraArgs, targetPath],
(error, stdout, stderr) => {
if (error) { if (error) {
reject(`error: ${error}`); reject(`error: ${error}`);
} }
@@ -726,6 +750,7 @@ export async function convert(
} }
resolve(message); resolve(message);
}); },
);
}); });
} }