X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo.ts;h=9111c71b0eb344cb9c1fb11baeb59e7e0fe8b002;hb=57a9b61a4aeead74e8800bbfad82ef433313b204;hp=1f103f930a76a7cecd174cb216ca4e1e28ea40a1;hpb=d17c7b4e8c52317bdc874917387b7a49f6cf8b01;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 1f103f930..9111c71b0 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -32,7 +32,8 @@ import { getHLSDirectory, getHLSRedundancyDirectory } from '@server/lib/paths' 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, uuidToShort } from '@shared/core-utils' +import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' +import { ffprobePromise, getAudioStream, uuidToShort } from '@shared/extra-utils' import { ResultList, ThumbnailType, @@ -1487,7 +1488,8 @@ export class VideoModel extends Model>> { required: false, where: { startDate: { - [Op.gte]: new Date(new Date().getTime() - (24 * 3600 * 1000) * trendingDays) + // FIXME: ts error + [Op.gte as any]: new Date(new Date().getTime() - (24 * 3600 * 1000) * trendingDays) } } } @@ -1677,12 +1679,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) + } }) }