1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-19 18:26:46 +01:00

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
This commit is contained in:
kasgel 2023-07-09 22:15:34 +02:00 committed by GitHub
parent 398bd04ffd
commit 50f26374e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -142,7 +142,7 @@ export class MediaService {
const mainVideoStream = this.getMainVideoStream(videoStreams); const mainVideoStream = this.getMainVideoStream(videoStreams);
const mainAudioStream = this.getMainAudioStream(audioStreams); const mainAudioStream = this.getMainAudioStream(audioStreams);
const containerExtension = format.formatName; const containerExtension = format.formatName;
if (!mainVideoStream || !mainAudioStream || !containerExtension) { if (!mainVideoStream || !containerExtension) {
return false; return false;
} }
@ -182,7 +182,7 @@ export class MediaService {
private isTranscodeRequired( private isTranscodeRequired(
asset: AssetEntity, asset: AssetEntity,
videoStream: VideoStreamInfo, videoStream: VideoStreamInfo,
audioStream: AudioStreamInfo, audioStream: AudioStreamInfo | null,
containerExtension: string, containerExtension: string,
ffmpegConfig: SystemConfigFFmpegDto, ffmpegConfig: SystemConfigFFmpegDto,
): boolean { ): boolean {
@ -192,12 +192,18 @@ export class MediaService {
} }
const isTargetVideoCodec = videoStream.codecName === ffmpegConfig.targetVideoCodec; 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 isTargetContainer = ['mov,mp4,m4a,3gp,3g2,mj2', 'mp4', 'mov'].includes(containerExtension);
const isTargetAudioCodec = audioStream == null || audioStream.codecName === ffmpegConfig.targetAudioCodec;
this.logger.verbose( if (audioStream != null) {
`${asset.id}: AudioCodecName ${audioStream.codecName}, AudioStreamCodecType ${audioStream.codecType}, containerExtension ${containerExtension}`, 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 allTargetsMatching = isTargetVideoCodec && isTargetAudioCodec && isTargetContainer;
const scalingEnabled = ffmpegConfig.targetResolution !== 'original'; const scalingEnabled = ffmpegConfig.targetResolution !== 'original';