diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/job-queue/handlers/video-live-ending.ts | 14 | ||||
-rw-r--r-- | server/lib/transcoding/transcoding.ts | 6 |
2 files changed, 8 insertions, 12 deletions
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index 79002258c..8a3ee09a2 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 @@ | |||
1 | import { Job } from 'bullmq' | 1 | import { Job } from 'bullmq' |
2 | import { readdir, remove } from 'fs-extra' | 2 | import { readdir, remove } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamDuration } from '@server/helpers/ffmpeg' | 4 | import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo } from '@server/helpers/ffmpeg' |
5 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' | 5 | import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' |
6 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' | 6 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' |
7 | import { cleanupPermanentLive, cleanupTMPLiveFiles, cleanupUnsavedNormalLive } from '@server/lib/live' | 7 | import { cleanupPermanentLive, cleanupTMPLiveFiles, cleanupUnsavedNormalLive } from '@server/lib/live' |
@@ -203,8 +203,6 @@ async function assignReplayFilesToVideo (options: { | |||
203 | }) { | 203 | }) { |
204 | const { video, replayDirectory } = options | 204 | const { video, replayDirectory } = options |
205 | 205 | ||
206 | let durationDone = false | ||
207 | |||
208 | const concatenatedTsFiles = await readdir(replayDirectory) | 206 | const concatenatedTsFiles = await readdir(replayDirectory) |
209 | 207 | ||
210 | for (const concatenatedTsFile of concatenatedTsFiles) { | 208 | for (const concatenatedTsFile of concatenatedTsFiles) { |
@@ -212,22 +210,14 @@ async function assignReplayFilesToVideo (options: { | |||
212 | 210 | ||
213 | const probe = await ffprobePromise(concatenatedTsFilePath) | 211 | const probe = await ffprobePromise(concatenatedTsFilePath) |
214 | const { audioStream } = await getAudioStream(concatenatedTsFilePath, probe) | 212 | const { audioStream } = await getAudioStream(concatenatedTsFilePath, probe) |
215 | |||
216 | const { resolution } = await getVideoStreamDimensionsInfo(concatenatedTsFilePath, probe) | 213 | const { resolution } = await getVideoStreamDimensionsInfo(concatenatedTsFilePath, probe) |
217 | 214 | ||
218 | const { resolutionPlaylistPath: outputPath } = await generateHlsPlaylistResolutionFromTS({ | 215 | await generateHlsPlaylistResolutionFromTS({ |
219 | video, | 216 | video, |
220 | concatenatedTsFilePath, | 217 | concatenatedTsFilePath, |
221 | resolution, | 218 | resolution, |
222 | isAAC: audioStream?.codec_name === 'aac' | 219 | isAAC: audioStream?.codec_name === 'aac' |
223 | }) | 220 | }) |
224 | |||
225 | if (!durationDone) { | ||
226 | video.duration = await getVideoStreamDuration(outputPath) | ||
227 | await video.save() | ||
228 | |||
229 | durationDone = true | ||
230 | } | ||
231 | } | 221 | } |
232 | 222 | ||
233 | return video | 223 | return video |
diff --git a/server/lib/transcoding/transcoding.ts b/server/lib/transcoding/transcoding.ts index 07eee4122..44e26754d 100644 --- a/server/lib/transcoding/transcoding.ts +++ b/server/lib/transcoding/transcoding.ts | |||
@@ -342,6 +342,12 @@ async function generateHlsPlaylistCommon (options: { | |||
342 | // Move video file | 342 | // Move video file |
343 | await move(join(videoTranscodedBasePath, videoFilename), videoFilePath, { overwrite: true }) | 343 | await move(join(videoTranscodedBasePath, videoFilename), videoFilePath, { overwrite: true }) |
344 | 344 | ||
345 | // Update video duration if it was not set (in case of a live for example) | ||
346 | if (!video.duration) { | ||
347 | video.duration = await getVideoStreamDuration(videoFilePath) | ||
348 | await video.save() | ||
349 | } | ||
350 | |||
345 | const stats = await stat(videoFilePath) | 351 | const stats = await stat(videoFilePath) |
346 | 352 | ||
347 | newVideoFile.size = stats.size | 353 | newVideoFile.size = stats.size |