aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-10 09:53:55 +0100
committerChocobozzz <me@florianbigard.com>2021-11-10 09:53:55 +0100
commit93904032506dd222404d9be60fd2e41763554665 (patch)
tree15900a11502a0110b8ab8709385a9bcae2cd6fed /server/helpers
parent020d3d3d79338148873cfd78ba59856f63260f2f (diff)
downloadPeerTube-93904032506dd222404d9be60fd2e41763554665.tar.gz
PeerTube-93904032506dd222404d9be60fd2e41763554665.tar.zst
PeerTube-93904032506dd222404d9be60fd2e41763554665.zip
Add ffmpeg tags for ffmpeg logs
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/ffmpeg-utils.ts33
1 files changed, 18 insertions, 15 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index ec24f357b..cc79828f6 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -16,7 +16,9 @@ import { CONFIG } from '../initializers/config'
16import { execPromise, promisify0 } from './core-utils' 16import { execPromise, promisify0 } from './core-utils'
17import { computeFPS, ffprobePromise, getAudioStream, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from './ffprobe-utils' 17import { computeFPS, ffprobePromise, getAudioStream, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from './ffprobe-utils'
18import { processImage } from './image-utils' 18import { processImage } from './image-utils'
19import { logger } from './logger' 19import { logger, loggerTagsFactory } from './logger'
20
21const lTags = loggerTagsFactory('ffmpeg')
20 22
21/** 23/**
22 * 24 *
@@ -60,7 +62,7 @@ async function checkFFmpegEncoders (peertubeAvailableEncoders: AvailableEncoders
60 supportedEncoders.set(searchEncoder, availableFFmpegEncoders[searchEncoder] !== undefined) 62 supportedEncoders.set(searchEncoder, availableFFmpegEncoders[searchEncoder] !== undefined)
61 } 63 }
62 64
63 logger.info('Built supported ffmpeg encoders.', { supportedEncoders, searchEncoders }) 65 logger.info('Built supported ffmpeg encoders.', { supportedEncoders, searchEncoders, ...lTags() })
64 66
65 return supportedEncoders 67 return supportedEncoders
66} 68}
@@ -115,12 +117,12 @@ async function generateImageFromVideoFile (fromPath: string, folder: string, ima
115 const destination = join(folder, imageName) 117 const destination = join(folder, imageName)
116 await processImage(pendingImagePath, destination, size) 118 await processImage(pendingImagePath, destination, size)
117 } catch (err) { 119 } catch (err) {
118 logger.error('Cannot generate image from video %s.', fromPath, { err }) 120 logger.error('Cannot generate image from video %s.', fromPath, { err, ...lTags() })
119 121
120 try { 122 try {
121 await remove(pendingImagePath) 123 await remove(pendingImagePath)
122 } catch (err) { 124 } catch (err) {
123 logger.debug('Cannot remove pending image path after generation error.', { err }) 125 logger.debug('Cannot remove pending image path after generation error.', { err, ...lTags() })
124 } 126 }
125 } 127 }
126} 128}
@@ -202,7 +204,7 @@ const builders: {
202} 204}
203 205
204async function transcode (options: TranscodeOptions) { 206async function transcode (options: TranscodeOptions) {
205 logger.debug('Will run transcode.', { options }) 207 logger.debug('Will run transcode.', { options, ...lTags() })
206 208
207 let command = getFFmpeg(options.inputPath, 'vod') 209 let command = getFFmpeg(options.inputPath, 'vod')
208 .output(options.outputPath) 210 .output(options.outputPath)
@@ -284,7 +286,7 @@ async function getLiveTranscodingCommand (options: {
284 286
285 addDefaultEncoderParams({ command, encoder: builderResult.encoder, fps: resolutionFPS, streamNum: i }) 287 addDefaultEncoderParams({ command, encoder: builderResult.encoder, fps: resolutionFPS, streamNum: i })
286 288
287 logger.debug('Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile, builderResult) 289 logger.debug('Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile, builderResult, lTags())
288 290
289 command.outputOption(`${buildStreamSuffix('-c:v', i)} ${builderResult.encoder}`) 291 command.outputOption(`${buildStreamSuffix('-c:v', i)} ${builderResult.encoder}`)
290 applyEncoderOptions(command, builderResult.result) 292 applyEncoderOptions(command, builderResult.result)
@@ -308,7 +310,7 @@ async function getLiveTranscodingCommand (options: {
308 310
309 addDefaultEncoderParams({ command, encoder: builderResult.encoder, fps: resolutionFPS, streamNum: i }) 311 addDefaultEncoderParams({ command, encoder: builderResult.encoder, fps: resolutionFPS, streamNum: i })
310 312
311 logger.debug('Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult) 313 logger.debug('Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult, lTags())
312 314
313 command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`) 315 command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`)
314 applyEncoderOptions(command, builderResult.result) 316 applyEncoderOptions(command, builderResult.result)
@@ -531,12 +533,12 @@ async function getEncoderBuilderResult (options: EncoderOptionsBuilderParams & {
531 533
532 for (const encoder of encodersToTry) { 534 for (const encoder of encodersToTry) {
533 if (!(await checkFFmpegEncoders(availableEncoders)).get(encoder)) { 535 if (!(await checkFFmpegEncoders(availableEncoders)).get(encoder)) {
534 logger.debug('Encoder %s not available in ffmpeg, skipping.', encoder) 536 logger.debug('Encoder %s not available in ffmpeg, skipping.', encoder, lTags())
535 continue 537 continue
536 } 538 }
537 539
538 if (!encoders[encoder]) { 540 if (!encoders[encoder]) {
539 logger.debug('Encoder %s not available in peertube encoders, skipping.', encoder) 541 logger.debug('Encoder %s not available in peertube encoders, skipping.', encoder, lTags())
540 continue 542 continue
541 } 543 }
542 544
@@ -545,11 +547,11 @@ async function getEncoderBuilderResult (options: EncoderOptionsBuilderParams & {
545 let builder = builderProfiles[profile] 547 let builder = builderProfiles[profile]
546 548
547 if (!builder) { 549 if (!builder) {
548 logger.debug('Profile %s for encoder %s not available. Fallback to default.', profile, encoder) 550 logger.debug('Profile %s for encoder %s not available. Fallback to default.', profile, encoder, lTags())
549 builder = builderProfiles.default 551 builder = builderProfiles.default
550 552
551 if (!builder) { 553 if (!builder) {
552 logger.debug('Default profile for encoder %s not available. Try next available encoder.', encoder) 554 logger.debug('Default profile for encoder %s not available. Try next available encoder.', encoder, lTags())
553 continue 555 continue
554 } 556 }
555 } 557 }
@@ -619,7 +621,8 @@ async function presetVideo (options: {
619 621
620 logger.debug( 622 logger.debug(
621 'Apply ffmpeg params from %s for %s stream of input %s using %s profile.', 623 'Apply ffmpeg params from %s for %s stream of input %s using %s profile.',
622 builderResult.encoder, streamType, input, profile, builderResult 624 builderResult.encoder, streamType, input, profile, builderResult,
625 lTags()
623 ) 626 )
624 627
625 if (streamType === 'video') { 628 if (streamType === 'video') {
@@ -725,13 +728,13 @@ async function runCommand (options: {
725 command.on('start', cmdline => { shellCommand = cmdline }) 728 command.on('start', cmdline => { shellCommand = cmdline })
726 729
727 command.on('error', (err, stdout, stderr) => { 730 command.on('error', (err, stdout, stderr) => {
728 if (silent !== true) logger.error('Error in ffmpeg.', { stdout, stderr }) 731 if (silent !== true) logger.error('Error in ffmpeg.', { stdout, stderr, ...lTags() })
729 732
730 rej(err) 733 rej(err)
731 }) 734 })
732 735
733 command.on('end', (stdout, stderr) => { 736 command.on('end', (stdout, stderr) => {
734 logger.debug('FFmpeg command ended.', { stdout, stderr, shellCommand }) 737 logger.debug('FFmpeg command ended.', { stdout, stderr, shellCommand, ...lTags() })
735 738
736 res() 739 res()
737 }) 740 })
@@ -741,7 +744,7 @@ async function runCommand (options: {
741 if (!progress.percent) return 744 if (!progress.percent) return
742 745
743 job.progress(Math.round(progress.percent)) 746 job.progress(Math.round(progress.percent))
744 .catch(err => logger.warn('Cannot set ffmpeg job progress.', { err })) 747 .catch(err => logger.warn('Cannot set ffmpeg job progress.', { err, ...lTags() }))
745 }) 748 })
746 } 749 }
747 750