added a configuration option to select the dri node in transcoding (#6376)
* added a configuration option to select the dri node in transcoding * chore: open api * refactor: get hawrdware device --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
@@ -285,6 +285,20 @@ export class BaseHWConfig extends BaseConfig implements VideoCodecHWConfig {
|
||||
}
|
||||
return this.config.gopSize;
|
||||
}
|
||||
|
||||
getPreferredHardwareDevice(): string | null {
|
||||
const device = this.config.preferredHwDevice;
|
||||
if (device === 'auto') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const deviceName = device.replace('/dev/dri/', '');
|
||||
if (!this.devices.includes(deviceName)) {
|
||||
throw new Error(`Device '${device}' does not exist`);
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
}
|
||||
|
||||
export class ThumbnailConfig extends BaseConfig {
|
||||
@@ -463,7 +477,14 @@ export class QSVConfig extends BaseHWConfig {
|
||||
if (!this.devices.length) {
|
||||
throw Error('No QSV device found');
|
||||
}
|
||||
return ['-init_hw_device qsv=hw', '-filter_hw_device hw'];
|
||||
|
||||
let qsvString = '';
|
||||
const hwDevice = this.getPreferredHardwareDevice();
|
||||
if (hwDevice !== null) {
|
||||
qsvString = `,child_device=${hwDevice}`;
|
||||
}
|
||||
|
||||
return [`-init_hw_device qsv=hw${qsvString}`, '-filter_hw_device hw'];
|
||||
}
|
||||
|
||||
getBaseOutputOptions(videoStream: VideoStreamInfo, audioStream?: AudioStreamInfo) {
|
||||
@@ -527,9 +548,15 @@ export class QSVConfig extends BaseHWConfig {
|
||||
export class VAAPIConfig extends BaseHWConfig {
|
||||
getBaseInputOptions() {
|
||||
if (this.devices.length === 0) {
|
||||
throw Error('No VAAPI device found');
|
||||
throw new Error('No VAAPI device found');
|
||||
}
|
||||
return [`-init_hw_device vaapi=accel:/dev/dri/${this.devices[0]}`, '-filter_hw_device accel'];
|
||||
|
||||
let hwDevice = this.getPreferredHardwareDevice();
|
||||
if (hwDevice === null) {
|
||||
hwDevice = `/dev/dri/${this.devices[0]}`;
|
||||
}
|
||||
|
||||
return [`-init_hw_device vaapi=accel:${hwDevice}`, '-filter_hw_device accel'];
|
||||
}
|
||||
|
||||
getFilterOptions(videoStream: VideoStreamInfo) {
|
||||
|
||||
Reference in New Issue
Block a user