fix: отключать av1 при отсутствии hw и отражать в выводе
This commit is contained in:
18
src/cli.ts
18
src/cli.ts
@@ -152,6 +152,7 @@ console.log('🔍 Checking system...\n');
|
||||
const hasFFmpeg = await checkFFmpeg();
|
||||
const hasMP4Box = await checkMP4Box();
|
||||
const hwEncoders = await detectHardwareEncoders();
|
||||
const hasAv1Hardware = hwEncoders.some(item => item.av1Encoder);
|
||||
|
||||
const accelPriority: Record<string, number> = {
|
||||
nvenc: 100,
|
||||
@@ -188,12 +189,15 @@ if (!hasMP4Box) {
|
||||
}
|
||||
|
||||
// Validate codec selection
|
||||
const hasAv1Hardware = hwEncoders.some(item => item.av1Encoder);
|
||||
|
||||
if ((codecType === 'av1' || codecType === 'dual') && !hasAv1Hardware) {
|
||||
console.error(`⚠️ Warning: AV1 encoding requested but no hardware AV1 encoder found.`);
|
||||
console.error(` CPU-based AV1 encoding (libsvtav1) will be VERY slow.`);
|
||||
console.error(` Consider using --codec h264 for faster encoding.\n`);
|
||||
if (codecType === 'av1') {
|
||||
console.error(`⚠️ Warning: AV1 encoding requested but no hardware AV1 encoder found.`);
|
||||
console.error(` CPU-based AV1 encoding (libsvtav1) will be VERY slow.`);
|
||||
console.error(` Consider using --codec h264 for faster encoding.\n`);
|
||||
} else if (codecType === 'dual') {
|
||||
console.warn(`⚠️ AV1 hardware encoder not detected. Using H.264 only (disable AV1).`);
|
||||
codecType = 'h264';
|
||||
}
|
||||
}
|
||||
|
||||
// Validate HLS requires H.264
|
||||
@@ -262,11 +266,13 @@ const manifestDesc =
|
||||
|
||||
const thumbnailsPlanned = true;
|
||||
const posterPlanned = posterTimecode || '00:00:00';
|
||||
const codecDisplay = codecType === 'dual' ? 'dual (AV1 + H.264)' : codecType;
|
||||
const codecNote = codecType === 'h264' && accelRest && accelRest.length >= 0 && !hasAv1Hardware ? ' (AV1 disabled: no HW)' : '';
|
||||
|
||||
console.log('\n📦 Parameters:');
|
||||
console.log(` Input: ${input}`);
|
||||
console.log(` Output: ${outputDir}`);
|
||||
console.log(` Codec: ${codecType}${codecType === 'dual' ? ' (AV1 + H.264)' : ''}`);
|
||||
console.log(` Codec: ${codecDisplay}${codecNote}`);
|
||||
console.log(` Profiles: ${displayProfiles.join(', ')}`);
|
||||
console.log(` Manifests: ${manifestDesc}`);
|
||||
console.log(` Poster: ${posterPlanned} (will be generated)`);
|
||||
|
||||
@@ -184,6 +184,14 @@ async function convertToDashInternal(
|
||||
}
|
||||
}
|
||||
|
||||
const av1HardwareAvailable = hardwareEncoders.some(info => info.av1Encoder);
|
||||
|
||||
let effectiveCodec: CodecType = codec;
|
||||
if (codec === 'dual' && !av1HardwareAvailable) {
|
||||
console.warn('⚠️ AV1 hardware encoder not detected. Switching to H.264 only.');
|
||||
effectiveCodec = 'h264';
|
||||
}
|
||||
|
||||
// Select profiles
|
||||
let profiles: VideoProfile[];
|
||||
|
||||
@@ -253,13 +261,13 @@ async function convertToDashInternal(
|
||||
// Determine which codecs to use based on codec parameter
|
||||
const codecs: Array<{ type: 'h264' | 'av1'; codec: string; preset: string }> = [];
|
||||
|
||||
if (codec === 'h264' || codec === 'dual') {
|
||||
if (effectiveCodec === 'h264' || effectiveCodec === 'dual') {
|
||||
const h264Codec = h264Encoder || 'libx264';
|
||||
const h264Preset = resolvePresetForEncoder(h264Codec, 'h264');
|
||||
codecs.push({ type: 'h264', codec: h264Codec, preset: h264Preset });
|
||||
}
|
||||
|
||||
if (codec === 'av1' || codec === 'dual') {
|
||||
if (effectiveCodec === 'av1' || effectiveCodec === 'dual') {
|
||||
const av1Codec = av1Encoder || 'libsvtav1';
|
||||
const av1Preset = resolvePresetForEncoder(av1Codec, 'av1');
|
||||
codecs.push({ type: 'av1', codec: av1Codec, preset: av1Preset });
|
||||
@@ -330,7 +338,7 @@ async function convertToDashInternal(
|
||||
videoOutputDir,
|
||||
profiles,
|
||||
segmentDuration,
|
||||
codec,
|
||||
effectiveCodec,
|
||||
format,
|
||||
hasAudio
|
||||
);
|
||||
@@ -404,7 +412,7 @@ async function convertToDashInternal(
|
||||
profiles,
|
||||
usedNvenc: codecs.some(c => c.codec.includes('nvenc')),
|
||||
selectedAccelerator: selected,
|
||||
codecType: codec,
|
||||
codecType: effectiveCodec,
|
||||
format
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user