X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo.ts;h=12b9375743702ce9c4778584ad7d66e0dbbcd957;hb=3726c3725506d0f8a26ded34f42d7bcfb5d0e639;hp=efd4d84624dd14d54a5209483e2b14cb660a427e;hpb=06aad80165d09a8863ab8103149a8ff518b10641;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video.ts b/server/models/video/video.ts index efd4d8462..12b937574 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -25,7 +25,6 @@ import { UpdatedAt } from 'sequelize-typescript' import { buildNSFWFilter } from '@server/helpers/express-utils' -import { uuidToShort } from '@shared/core-utils/uuid' import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' import { LiveManager } from '@server/lib/live/live-manager' import { removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage' @@ -33,13 +32,24 @@ 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 { AttributesOnly, buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' -import { VideoFile, VideoInclude } from '@shared/models' -import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' -import { VideoObject } from '../../../shared/models/activitypub/objects' -import { Video, VideoDetails, VideoRateType, VideoStorage } from '../../../shared/models/videos' -import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type' -import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' +import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' +import { ffprobePromise, getAudioStream, uuidToShort } from '@shared/extra-utils' +import { + ResultList, + ThumbnailType, + UserRight, + Video, + VideoDetails, + VideoFile, + VideoInclude, + VideoObject, + VideoPrivacy, + VideoRateType, + VideoState, + VideoStorage, + VideoStreamingPlaylistType +} from '@shared/models' +import { AttributesOnly } from '@shared/typescript-utils' import { peertubeTruncate } from '../../helpers/core-utils' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' import { exists, isBooleanValid } from '../../helpers/custom-validators/misc' @@ -1668,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) + } }) }