ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix saved live master playlist bandwidth
Chocobozzze4fc3697acb2
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.tsindex 79002258cd..8a3ee09a22 100644--- a/server/lib/job-queue/handlers/video-live-ending.ts+++ b/server/lib/job-queue/handlers/video-live-ending.ts@@ -1,7 +1,7 @@import { Job } from 'bullmq'import { readdir, remove } from 'fs-extra'import { join } from 'path'-import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamDuration } from '@server/helpers/ffmpeg'+import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo } from '@server/helpers/ffmpeg'import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'import { cleanupPermanentLive, cleanupTMPLiveFiles, cleanupUnsavedNormalLive } from '@server/lib/live'@@ -203,8 +203,6 @@ async function assignReplayFilesToVideo (options: {}) {const { video, replayDirectory } = options- let durationDone = false-const concatenatedTsFiles = await readdir(replayDirectory)for (const concatenatedTsFile of concatenatedTsFiles) {@@ -212,22 +210,14 @@ async function assignReplayFilesToVideo (options: {const probe = await ffprobePromise(concatenatedTsFilePath)const { audioStream } = await getAudioStream(concatenatedTsFilePath, probe)-const { resolution } = await getVideoStreamDimensionsInfo(concatenatedTsFilePath, probe)- const { resolutionPlaylistPath: outputPath } = await generateHlsPlaylistResolutionFromTS({+ await generateHlsPlaylistResolutionFromTS({video,concatenatedTsFilePath,resolution,isAAC: audioStream?.codec_name === 'aac'})-- if (!durationDone) {- video.duration = await getVideoStreamDuration(outputPath)- await video.save()-- durationDone = true- }}return videodiff --git a/server/lib/transcoding/transcoding.ts b/server/lib/transcoding/transcoding.tsindex 07eee4122d..44e26754d5 100644--- a/server/lib/transcoding/transcoding.ts+++ b/server/lib/transcoding/transcoding.ts@@ -342,6 +342,12 @@ async function generateHlsPlaylistCommon (options: {// Move video fileawait move(join(videoTranscodedBasePath, videoFilename), videoFilePath, { overwrite: true })+ // Update video duration if it was not set (in case of a live for example)+ if (!video.duration) {+ video.duration = await getVideoStreamDuration(videoFilePath)+ await video.save()+ }+const stats = await stat(videoFilePath)newVideoFile.size = stats.sizediff --git a/server/models/video/video.ts b/server/models/video/video.tsindex a8ea67c395..468117504e 100644--- a/server/models/video/video.ts+++ b/server/models/video/video.ts@@ -1899,6 +1899,8 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {}getBandwidthBits (this: MVideo, videoFile: MVideoFile) {+ if (!this.duration) throw new Error(`Cannot get bandwidth bits because video ${this.url} has duration of 0`)+return Math.ceil((videoFile.size * 8) / this.duration)}