Fix live ending when using remote runners

This commit is contained in:
Chocobozzz 2025-02-11 14:50:53 +01:00
parent 66023f9c98
commit ac0bf90758
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 11 additions and 20 deletions

View File

@ -223,11 +223,13 @@ export class ProcessLiveRTMPHLSTranscoding {
private async onFFmpegEnded () {
if (this.ended) return
this.ended = true
logger.info('FFmpeg ended, sending success to server')
// Wait last ffmpeg chunks generation
await wait(1500)
await this.sendPendingChunks()
this.ended = true
this.sendSuccess()
.catch(err => logger.error({ err }, 'Cannot send success'))
@ -360,11 +362,17 @@ export class ProcessLiveRTMPHLSTranscoding {
private async updatePlaylistContent (playlistName: string, latestChunkFilename: string) {
const m3u8Path = join(this.outputPath, playlistName)
const playlistContent = await readFile(m3u8Path, 'utf-8')
let playlistContent = await readFile(m3u8Path, 'utf-8')
if (!playlistContent.includes('#EXT-X-ENDLIST')) {
playlistContent = playlistContent.substring(
0,
playlistContent.lastIndexOf(latestChunkFilename) + latestChunkFilename.length
) + '\n'
}
// Remove new chunk references, that will be processed later
this.latestFilteredPlaylistContent[playlistName] = playlistContent
.substring(0, playlistContent.lastIndexOf(latestChunkFilename) + latestChunkFilename.length) + '\n'
}
private buildPlaylistFileParam (playlistName: string) {

View File

@ -1,7 +1,6 @@
import { arrayify } from '@peertube/peertube-core-utils'
import {
HttpStatusCode,
RunnerJobLiveRTMPHLSTranscodingPrivatePayload,
RunnerJobState,
RunnerJobStateType,
RunnerJobSuccessBody,
@ -20,7 +19,6 @@ import {
} from '@server/helpers/custom-validators/runners/jobs.js'
import { isRunnerTokenValid } from '@server/helpers/custom-validators/runners/runners.js'
import { cleanUpReqFiles } from '@server/helpers/express-utils.js'
import { LiveManager } from '@server/lib/live/index.js'
import { runnerJobCanBeCancelled } from '@server/lib/runners/index.js'
import { RunnerJobModel } from '@server/models/runner/runner-job.js'
import express from 'express'
@ -72,21 +70,6 @@ export const updateRunnerJobValidator = [
})
}
if (res.locals.runnerJob.type === 'live-rtmp-hls-transcoding') {
const privatePayload = job.privatePayload as RunnerJobLiveRTMPHLSTranscodingPrivatePayload
if (!LiveManager.Instance.hasSession(privatePayload.sessionId)) {
cleanUpReqFiles(req)
return res.fail({
status: HttpStatusCode.BAD_REQUEST_400,
type: ServerErrorCode.RUNNER_JOB_NOT_IN_PROCESSING_STATE,
message: 'Session of this live ended',
tags
})
}
}
return next()
}
]