refactor: убрать useNvenc и разделить выбор энкодера/декодера
This commit is contained in:
@@ -5,6 +5,7 @@ export {
|
||||
checkNvenc,
|
||||
checkAV1Support,
|
||||
detectHardwareEncoders,
|
||||
detectHardwareDecoders,
|
||||
execFFmpeg,
|
||||
execMP4Box,
|
||||
setLogFile
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { spawn } from 'node:child_process';
|
||||
import { appendFile } from 'node:fs/promises';
|
||||
import type { HardwareAccelerator, HardwareEncoderInfo } from '../types';
|
||||
import type { HardwareAccelerator, HardwareDecoderInfo, HardwareEncoderInfo } from '../types';
|
||||
|
||||
// Global variable for log file path
|
||||
let currentLogFile: string | null = null;
|
||||
@@ -159,6 +159,40 @@ export async function detectHardwareEncoders(): Promise<HardwareEncoderInfo[]> {
|
||||
return detected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить список доступных аппаратных декодеров (по выводу ffmpeg -hwaccels)
|
||||
*/
|
||||
export async function detectHardwareDecoders(): Promise<HardwareDecoderInfo[]> {
|
||||
const output: string = await new Promise((resolve) => {
|
||||
const proc = spawn('ffmpeg', ['-hide_banner', '-hwaccels']);
|
||||
let data = '';
|
||||
proc.stdout.on('data', (chunk) => data += chunk.toString());
|
||||
proc.on('error', () => resolve(''));
|
||||
proc.on('close', () => resolve(data));
|
||||
});
|
||||
|
||||
const lines = output.split('\n').map(l => l.trim()).filter(Boolean);
|
||||
const decoders: HardwareDecoderInfo[] = [];
|
||||
|
||||
const map: Record<string, HardwareAccelerator> = {
|
||||
cuda: 'nvenc',
|
||||
qsv: 'qsv',
|
||||
vaapi: 'vaapi',
|
||||
videotoolbox: 'videotoolbox',
|
||||
v4l2m2m: 'v4l2',
|
||||
dxva2: 'amf'
|
||||
};
|
||||
|
||||
for (const line of lines) {
|
||||
const acc = map[line];
|
||||
if (acc) {
|
||||
decoders.push({ accelerator: acc });
|
||||
}
|
||||
}
|
||||
|
||||
return decoders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute FFmpeg command with progress tracking
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user