From cbe2f36d93c779ca08424336be7e3988e57be01d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 6 Jan 2022 17:55:37 +0100 Subject: Fix audio transcoding with video only file --- server/models/video/video.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'server/models') diff --git a/server/models/video/video.ts b/server/models/video/video.ts index e5077487a..12b937574 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -33,7 +33,7 @@ import { VideoPathManager } from '@server/lib/video-path-manager' import { getServerActor } from '@server/models/application/application' import { ModelCache } from '@server/models/model-cache' import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' -import { uuidToShort } from '@shared/extra-utils' +import { ffprobePromise, getAudioStream, uuidToShort } from '@shared/extra-utils' import { ResultList, ThumbnailType, @@ -1678,12 +1678,20 @@ export class VideoModel extends Model>> { return peertubeTruncate(this.description, { length: maxLength }) } - getMaxQualityResolution () { + getMaxQualityFileInfo () { const file = this.getMaxQualityFile() const videoOrPlaylist = file.getVideoOrStreamingPlaylist() - return VideoPathManager.Instance.makeAvailableVideoFile(file.withVideoOrPlaylist(videoOrPlaylist), originalFilePath => { - return getVideoFileResolution(originalFilePath) + return VideoPathManager.Instance.makeAvailableVideoFile(file.withVideoOrPlaylist(videoOrPlaylist), async originalFilePath => { + const probe = await ffprobePromise(originalFilePath) + + const { audioStream } = await getAudioStream(originalFilePath, probe) + + return { + audioStream, + + ...await getVideoFileResolution(originalFilePath, probe) + } }) } -- cgit v1.2.3