1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 01:39:37 +02:00

Ensure ffmpeg is killed

This commit is contained in:
Chocobozzz 2025-03-28 09:20:07 +01:00
parent 3e69a6ce19
commit 1a5c4ff11d
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 21 additions and 7 deletions

View file

@ -119,7 +119,9 @@ export class FFmpegCommandWrapper {
return new Promise<void>((res, rej) => {
let shellCommand: string
this.command.on('start', cmdline => { shellCommand = cmdline })
this.command.on('start', cmdline => {
shellCommand = cmdline
})
this.command.on('error', (err: Error & { stdout?: string, stderr?: string }, stdout, stderr) => {
if (silent !== true) this.logger.error('Error in ffmpeg.', { err, stdout, stderr, shellCommand, ...this.lTags })
@ -166,12 +168,14 @@ export class FFmpegCommandWrapper {
// Run encoder builder depending on available encoders
// Try encoders by priority: if the encoder is available, run the chosen profile or fallback to the default one
// If the default one does not exist, check the next encoder
async getEncoderBuilderResult (options: EncoderOptionsBuilderParams & {
streamType: 'video' | 'audio'
input: string
async getEncoderBuilderResult (
options: EncoderOptionsBuilderParams & {
streamType: 'video' | 'audio'
input: string
videoType: 'vod' | 'live'
}) {
videoType: 'vod' | 'live'
}
) {
if (!this.availableEncoders) {
throw new Error('There is no available encoders')
}

View file

@ -30,4 +30,10 @@ export class FFmpegContainer {
return this.commandWrapper.runCommand({ silent: !logError })
}
forceKill () {
if (!this.commandWrapper) return
this.commandWrapper.getCommand().kill('SIGKILL')
}
}

View file

@ -303,8 +303,10 @@ export async function muxToMergeVideoFiles (options: {
logger.info(`Muxing files for video ${video.url}`, { inputs: inputsToLog, ...lTags(video.uuid) })
const ffmpegContainer = new FFmpegContainer(getFFmpegCommandWrapperOptions('vod'))
try {
await new FFmpegContainer(getFFmpegCommandWrapperOptions('vod')).mergeInputs({
await ffmpegContainer.mergeInputs({
inputs,
output,
logError: false,
@ -329,6 +331,8 @@ export async function muxToMergeVideoFiles (options: {
}
throw err
} finally {
ffmpegContainer.forceKill()
}
} finally {
for (const destination of tmpDestinations) {