Fix live saving after a server restart
This commit is contained in:
parent
a742b4b0e2
commit
8c666c44ab
|
@ -1,8 +1,9 @@
|
||||||
import * as Bull from 'bull'
|
import * as Bull from 'bull'
|
||||||
import { move, readdir, remove } from 'fs-extra'
|
import { copy, readdir, remove } from 'fs-extra'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { hlsPlaylistToFragmentedMP4 } from '@server/helpers/ffmpeg-utils'
|
import { hlsPlaylistToFragmentedMP4 } from '@server/helpers/ffmpeg-utils'
|
||||||
import { getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils'
|
import { getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils'
|
||||||
|
import { VIDEO_LIVE } from '@server/initializers/constants'
|
||||||
import { generateVideoMiniature } from '@server/lib/thumbnail'
|
import { generateVideoMiniature } from '@server/lib/thumbnail'
|
||||||
import { publishAndFederateIfNeeded } from '@server/lib/video'
|
import { publishAndFederateIfNeeded } from '@server/lib/video'
|
||||||
import { getHLSDirectory } from '@server/lib/video-paths'
|
import { getHLSDirectory } from '@server/lib/video-paths'
|
||||||
|
@ -14,7 +15,6 @@ import { VideoStreamingPlaylistModel } from '@server/models/video/video-streamin
|
||||||
import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models'
|
import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models'
|
||||||
import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
|
import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
|
||||||
import { logger } from '../../../helpers/logger'
|
import { logger } from '../../../helpers/logger'
|
||||||
import { VIDEO_LIVE } from '@server/initializers/constants'
|
|
||||||
|
|
||||||
async function processVideoLiveEnding (job: Bull.Job) {
|
async function processVideoLiveEnding (job: Bull.Job) {
|
||||||
const payload = job.data as VideoLiveEndingPayload
|
const payload = job.data as VideoLiveEndingPayload
|
||||||
|
@ -61,11 +61,12 @@ async function saveLive (video: MVideo, live: MVideoLive) {
|
||||||
const playlistFiles: string[] = []
|
const playlistFiles: string[] = []
|
||||||
|
|
||||||
for (const file of rootFiles) {
|
for (const file of rootFiles) {
|
||||||
if (file.endsWith('.m3u8') !== true) continue
|
// Move remaining files in the replay directory
|
||||||
|
if (file.endsWith('.ts') || file.endsWith('.m3u8')) {
|
||||||
|
await copy(join(hlsDirectory, file), join(replayDirectory, file))
|
||||||
|
}
|
||||||
|
|
||||||
await move(join(hlsDirectory, file), join(replayDirectory, file))
|
if (file.endsWith('.m3u8') && file !== 'master.m3u8') {
|
||||||
|
|
||||||
if (file !== 'master.m3u8') {
|
|
||||||
playlistFiles.push(file)
|
playlistFiles.push(file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue