X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fffmpeg-utils.ts;h=62002596664441c7f244311853119b2aee13f767;hb=db8b2f56c014a3fa207501f74e0bb5088ea41719;hp=33c625c9ef659a310fd6b6b1c99cd486ba0e45b4;hpb=1896bca09e088b0da9d5e845407ecebae330618c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 33c625c9e..620025966 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -69,7 +69,7 @@ function convertWebPToJPG (path: string, destination: string): Promise { const command = ffmpeg(path, { niceness: FFMPEG_NICE.THUMBNAIL }) .output(destination) - return runCommand(command) + return runCommand({ command, silent: true }) } function processGIF ( @@ -82,7 +82,7 @@ function processGIF ( .size(`${newSize.width}x${newSize.height}`) .output(destination) - return runCommand(command) + return runCommand({ command }) } async function generateImageFromVideoFile (fromPath: string, folder: string, imageName: string, size: { width: number, height: number }) { @@ -201,7 +201,7 @@ async function transcode (options: TranscodeOptions) { command = await builders[options.type](command, options) - await runCommand(command, options.job) + await runCommand({ command, job: options.job }) await fixHLSPlaylistIfNeeded(options) } @@ -649,10 +649,17 @@ function getFFmpeg (input: string, type: 'live' | 'vod') { return command } -async function runCommand (command: ffmpeg.FfmpegCommand, job?: Job) { +async function runCommand (options: { + command: ffmpeg.FfmpegCommand + silent?: boolean // false + job?: Job +}) { + const { command, silent = false, job } = options + return new Promise((res, rej) => { command.on('error', (err, stdout, stderr) => { - logger.error('Error in transcoding job.', { stdout, stderr }) + if (silent !== true) logger.error('Error in ffmpeg.', { stdout, stderr }) + rej(err) })