refactor: update codec detection logic to focus on container formats
- Replaced the previous imageFormats set with a new containerFormats set to optimize ffprobe usage. - Updated the isCudaSupportedCodec function to only probe container formats that can contain video streams, improving performance and clarity in codec detection. These changes enhance the efficiency of the codec detection process for CUDA hardware acceleration.
This commit is contained in:
parent
c9b43e11da
commit
5ec86d624f
1 changed files with 34 additions and 31 deletions
|
|
@ -691,33 +691,36 @@ export const properties = {
|
||||||
// CUDA-supported codec names (as detected by ffprobe)
|
// CUDA-supported codec names (as detected by ffprobe)
|
||||||
const cudaSupportedCodecs = new Set(["h264", "hevc", "vp9", "vp8", "mpeg2video", "mpeg4", "av1"]);
|
const cudaSupportedCodecs = new Set(["h264", "hevc", "vp9", "vp8", "mpeg2video", "mpeg4", "av1"]);
|
||||||
|
|
||||||
// Known image formats that should skip ffprobe (no video codec to detect)
|
// Container formats that can contain video streams with unknown codecs (run ffprobe)
|
||||||
const imageFormats = new Set([
|
const containerFormats = new Set([
|
||||||
"jpg",
|
// Most common/popular video containers
|
||||||
"jpeg",
|
"avi",
|
||||||
"png",
|
"mkv",
|
||||||
"gif",
|
"mov",
|
||||||
"bmp",
|
"mp4",
|
||||||
"webp",
|
"m4v", // MPEG-4 video
|
||||||
"ico",
|
"m4a", // MPEG-4 audio
|
||||||
"tiff",
|
"webm",
|
||||||
"tif",
|
"flv",
|
||||||
"svg",
|
"wmv",
|
||||||
"avif",
|
"vob", // DVD video
|
||||||
"jxl",
|
// MPEG transport streams
|
||||||
"heic",
|
"m2ts",
|
||||||
"heif",
|
"ts",
|
||||||
"raw",
|
"mts",
|
||||||
"cr2",
|
// MPEG containers
|
||||||
"nef",
|
"mpeg",
|
||||||
"orf",
|
"mpg",
|
||||||
"sr2",
|
"m2v", // MPEG-2 video
|
||||||
"arw",
|
// Mobile/legacy formats
|
||||||
"dng",
|
"3gp",
|
||||||
"psd",
|
"3g2",
|
||||||
"xcf",
|
// Other containers
|
||||||
"exr",
|
"nut",
|
||||||
"hdr",
|
"ogv", // OGG video
|
||||||
|
"asf",
|
||||||
|
"mxf", // Professional video
|
||||||
|
"f4v", // Flash video
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Cache NVIDIA GPU availability to avoid repeated checks
|
// Cache NVIDIA GPU availability to avoid repeated checks
|
||||||
|
|
@ -767,7 +770,7 @@ async function checkNvidiaGpuAvailable(execFile: ExecFileFn = execFileOriginal):
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses ffprobe to detect if the video codec in a file is supported by CUDA hardware acceleration.
|
* Uses ffprobe to detect if the video codec in a file is supported by CUDA hardware acceleration.
|
||||||
* Returns false for image formats without probing (performance optimization).
|
* Only probes container formats that can contain video streams with unknown codecs.
|
||||||
* Falls back to false if probing fails (safe default).
|
* Falls back to false if probing fails (safe default).
|
||||||
*/
|
*/
|
||||||
async function isCudaSupportedCodec(
|
async function isCudaSupportedCodec(
|
||||||
|
|
@ -775,9 +778,9 @@ async function isCudaSupportedCodec(
|
||||||
fileType: string,
|
fileType: string,
|
||||||
execFile: ExecFileFn = execFileOriginal,
|
execFile: ExecFileFn = execFileOriginal,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
// Skip ffprobe for known image formats (no video codec to detect)
|
// Only run ffprobe on container formats that can contain video streams
|
||||||
if (imageFormats.has(fileType.toLowerCase())) {
|
if (!containerFormats.has(fileType.toLowerCase())) {
|
||||||
console.log(`Skipping CUDA detection for image format: ${fileType}`);
|
console.log(`Skipping CUDA detection for non-container format: ${fileType}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue