aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/video-live-ending.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-10-28 10:49:20 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitd846d99c6c81028bb7bd3cb20abd433cbf396a22 (patch)
tree1090abd56e9b2df82dd92783f499ac9f10fbd501 /server/lib/job-queue/handlers/video-live-ending.ts
parent31c82cd914e13dbf53280d0aad0740d70c414441 (diff)
downloadPeerTube-d846d99c6c81028bb7bd3cb20abd433cbf396a22.tar.gz
PeerTube-d846d99c6c81028bb7bd3cb20abd433cbf396a22.tar.zst
PeerTube-d846d99c6c81028bb7bd3cb20abd433cbf396a22.zip
Add modal to display live information
Diffstat (limited to 'server/lib/job-queue/handlers/video-live-ending.ts')
-rw-r--r--server/lib/job-queue/handlers/video-live-ending.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts
index cd5bb1d1c..32eeff4d1 100644
--- a/server/lib/job-queue/handlers/video-live-ending.ts
+++ b/server/lib/job-queue/handlers/video-live-ending.ts
@@ -1,7 +1,8 @@
1import * as Bull from 'bull' 1import * as Bull from 'bull'
2import { readdir, remove } from 'fs-extra' 2import { readdir, remove } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import { getVideoFileResolution, hlsPlaylistToFragmentedMP4 } from '@server/helpers/ffmpeg-utils' 4import { getDurationFromVideoFile, getVideoFileResolution, hlsPlaylistToFragmentedMP4 } from '@server/helpers/ffmpeg-utils'
5import { publishAndFederateIfNeeded } from '@server/lib/video'
5import { getHLSDirectory } from '@server/lib/video-paths' 6import { getHLSDirectory } from '@server/lib/video-paths'
6import { generateHlsPlaylist } from '@server/lib/video-transcoding' 7import { generateHlsPlaylist } from '@server/lib/video-transcoding'
7import { VideoModel } from '@server/models/video/video' 8import { VideoModel } from '@server/models/video/video'
@@ -44,6 +45,7 @@ async function saveLive (video: MVideo, live: MVideoLive) {
44 45
45 const playlistFiles = files.filter(f => f.endsWith('.m3u8') && f !== 'master.m3u8') 46 const playlistFiles = files.filter(f => f.endsWith('.m3u8') && f !== 'master.m3u8')
46 const resolutions: number[] = [] 47 const resolutions: number[] = []
48 let duration: number
47 49
48 for (const playlistFile of playlistFiles) { 50 for (const playlistFile of playlistFiles) {
49 const playlistPath = join(hlsDirectory, playlistFile) 51 const playlistPath = join(hlsDirectory, playlistFile)
@@ -58,6 +60,10 @@ async function saveLive (video: MVideo, live: MVideoLive) {
58 const segmentFiles = files.filter(f => f.startsWith(shouldStartWith) && f.endsWith('.ts')) 60 const segmentFiles = files.filter(f => f.startsWith(shouldStartWith) && f.endsWith('.ts'))
59 await hlsPlaylistToFragmentedMP4(hlsDirectory, segmentFiles, mp4TmpName) 61 await hlsPlaylistToFragmentedMP4(hlsDirectory, segmentFiles, mp4TmpName)
60 62
63 if (!duration) {
64 duration = await getDurationFromVideoFile(mp4TmpName)
65 }
66
61 resolutions.push(videoFileResolution) 67 resolutions.push(videoFileResolution)
62 } 68 }
63 69
@@ -67,6 +73,8 @@ async function saveLive (video: MVideo, live: MVideoLive) {
67 73
68 video.isLive = false 74 video.isLive = false
69 video.state = VideoState.TO_TRANSCODE 75 video.state = VideoState.TO_TRANSCODE
76 video.duration = duration
77
70 await video.save() 78 await video.save()
71 79
72 const videoWithFiles = await VideoModel.loadWithFiles(video.id) 80 const videoWithFiles = await VideoModel.loadWithFiles(video.id)
@@ -86,6 +94,8 @@ async function saveLive (video: MVideo, live: MVideoLive) {
86 94
87 video.state = VideoState.PUBLISHED 95 video.state = VideoState.PUBLISHED
88 await video.save() 96 await video.save()
97
98 await publishAndFederateIfNeeded(video)
89} 99}
90 100
91async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) { 101async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {