From 50f26374e3cbc818e2f9716e6000ed8c0e2a15ee Mon Sep 17 00:00:00 2001 From: kasgel Date: Sun, 9 Jul 2023 22:15:34 +0200 Subject: [PATCH] fix(server): enable transcoding of audioless videos (#3147) * Fix: enable transcoding of audioless videos * Fix: enable transcoding of audioless videos & typing * Fix: enable transcoding of audioless videos & formatting * fix: do not always transcode if there is no audio stream --- server/src/domain/media/media.service.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/server/src/domain/media/media.service.ts b/server/src/domain/media/media.service.ts index cfc04fba11..943da782dc 100644 --- a/server/src/domain/media/media.service.ts +++ b/server/src/domain/media/media.service.ts @@ -142,7 +142,7 @@ export class MediaService { const mainVideoStream = this.getMainVideoStream(videoStreams); const mainAudioStream = this.getMainAudioStream(audioStreams); const containerExtension = format.formatName; - if (!mainVideoStream || !mainAudioStream || !containerExtension) { + if (!mainVideoStream || !containerExtension) { return false; } @@ -182,7 +182,7 @@ export class MediaService { private isTranscodeRequired( asset: AssetEntity, videoStream: VideoStreamInfo, - audioStream: AudioStreamInfo, + audioStream: AudioStreamInfo | null, containerExtension: string, ffmpegConfig: SystemConfigFFmpegDto, ): boolean { @@ -192,12 +192,18 @@ export class MediaService { } const isTargetVideoCodec = videoStream.codecName === ffmpegConfig.targetVideoCodec; - const isTargetAudioCodec = audioStream.codecName === ffmpegConfig.targetAudioCodec; const isTargetContainer = ['mov,mp4,m4a,3gp,3g2,mj2', 'mp4', 'mov'].includes(containerExtension); + const isTargetAudioCodec = audioStream == null || audioStream.codecName === ffmpegConfig.targetAudioCodec; - this.logger.verbose( - `${asset.id}: AudioCodecName ${audioStream.codecName}, AudioStreamCodecType ${audioStream.codecType}, containerExtension ${containerExtension}`, - ); + if (audioStream != null) { + this.logger.verbose( + `${asset.id}: AudioCodecName ${audioStream.codecName}, AudioStreamCodecType ${audioStream.codecType}, containerExtension ${containerExtension}`, + ); + } else { + this.logger.verbose( + `${asset.id}: AudioCodecName None, AudioStreamCodecType None, containerExtension ${containerExtension}`, + ); + } const allTargetsMatching = isTargetVideoCodec && isTargetAudioCodec && isTargetContainer; const scalingEnabled = ffmpegConfig.targetResolution !== 'original';