mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 16:41:59 +00:00
if hw decoding failed with hw dec config enabled, try sw dec+hw enc first, then full sw dec+enc
This commit is contained in:
parent
88ca1f31ad
commit
18b93ddc73
2 changed files with 30 additions and 14 deletions
|
@ -341,10 +341,26 @@ export class MediaService extends BaseService {
|
||||||
if (ffmpeg.accel === TranscodeHWAccel.DISABLED) {
|
if (ffmpeg.accel === TranscodeHWAccel.DISABLED) {
|
||||||
return JobStatus.FAILED;
|
return JobStatus.FAILED;
|
||||||
}
|
}
|
||||||
this.logger.error(`Retrying with ${ffmpeg.accel.toUpperCase()} acceleration disabled`);
|
|
||||||
const config = BaseConfig.create({ ...ffmpeg, accel: TranscodeHWAccel.DISABLED });
|
let partialFallbackSuccess = false;
|
||||||
command = config.getCommand(target, mainVideoStream, mainAudioStream);
|
if (ffmpeg.accelDecode) {
|
||||||
await this.mediaRepository.transcode(input, output, command);
|
try {
|
||||||
|
this.logger.error(`Retrying with ${ffmpeg.accel.toUpperCase()} acceleration but software decoding`);
|
||||||
|
const config = BaseConfig.create({...ffmpeg, accelDecode: false});
|
||||||
|
command = config.getCommand(target, mainVideoStream, mainAudioStream);
|
||||||
|
await this.mediaRepository.transcode(input, output, command);
|
||||||
|
partialFallbackSuccess = true;
|
||||||
|
} catch (error: any) {
|
||||||
|
this.logger.error(`Error occurred during transcoding: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!partialFallbackSuccess) {
|
||||||
|
this.logger.error(`Retrying with ${ffmpeg.accel.toUpperCase()} acceleration disabled`);
|
||||||
|
const config = BaseConfig.create({...ffmpeg, accel: TranscodeHWAccel.DISABLED});
|
||||||
|
command = config.getCommand(target, mainVideoStream, mainAudioStream);
|
||||||
|
await this.mediaRepository.transcode(input, output, command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.log(`Successfully encoded ${asset.id}`);
|
this.logger.log(`Successfully encoded ${asset.id}`);
|
||||||
|
|
|
@ -924,8 +924,7 @@ export class RkmppSwDecodeConfig extends BaseHWConfig {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
getBaseInputOptions(): string[] {
|
||||||
getBaseInputOptions(videoStream: VideoStreamInfo): string[] {
|
|
||||||
if (this.devices.length === 0) {
|
if (this.devices.length === 0) {
|
||||||
throw new Error('No RKMPP device found');
|
throw new Error('No RKMPP device found');
|
||||||
}
|
}
|
||||||
|
@ -978,16 +977,12 @@ export class RkmppHwDecodeConfig extends RkmppSwDecodeConfig {
|
||||||
this.hasMaliOpenCL = hasMaliOpenCL;
|
this.hasMaliOpenCL = hasMaliOpenCL;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBaseInputOptions(videoStream: VideoStreamInfo) {
|
getBaseInputOptions() {
|
||||||
if (this.devices.length === 0) {
|
if (this.devices.length === 0) {
|
||||||
throw new Error('No RKMPP device found');
|
throw new Error('No RKMPP device found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.shouldToneMap(videoStream) || (this.shouldToneMap(videoStream) && this.hasMaliOpenCL)) {
|
return ['-hwaccel rkmpp', '-hwaccel_output_format drm_prime', '-afbc rga', '-noautorotate'];
|
||||||
return ['-hwaccel rkmpp', '-hwaccel_output_format drm_prime', '-afbc rga', '-noautorotate'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getFilterOptions(videoStream: VideoStreamInfo) {
|
getFilterOptions(videoStream: VideoStreamInfo) {
|
||||||
|
@ -1002,8 +997,13 @@ export class RkmppHwDecodeConfig extends RkmppSwDecodeConfig {
|
||||||
'format=drm_prime',
|
'format=drm_prime',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
// use CPU for scaling & tone mapping
|
return [ // use RKMPP for scaling, CPU for tone mapping (only works on RK3588 which support 10bit output)
|
||||||
return super.getFilterOptions(videoStream);
|
`scale_rkrga=${this.getScaling(videoStream)}:format=p010`,
|
||||||
|
'hwdownload',
|
||||||
|
'format=yuv420p10le',
|
||||||
|
`tonemapx=tonemap=${this.config.tonemap}:desat=0:p=${primaries}:t=${transfer}:m=${matrix}:r=pc:peak=100:format=yuv420p`,
|
||||||
|
'hwupload',
|
||||||
|
];
|
||||||
} else if (this.shouldScale(videoStream)) {
|
} else if (this.shouldScale(videoStream)) {
|
||||||
return [`scale_rkrga=${this.getScaling(videoStream)}:format=nv12:afbc=1`];
|
return [`scale_rkrga=${this.getScaling(videoStream)}:format=nv12:afbc=1`];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue