aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/ffmpeg-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-14 10:39:52 +0100
committerChocobozzz <me@florianbigard.com>2021-12-14 10:46:31 +0100
commit14857212f15256ff4dd0d36ff5158005f1d7caae (patch)
treed4aab7b8f5deb75018da86b7a83fc74d2b3da5cd /server/helpers/ffmpeg-utils.ts
parent9234110650495c05e04abee6a5934a27eb2f32a9 (diff)
downloadPeerTube-14857212f15256ff4dd0d36ff5158005f1d7caae.tar.gz
PeerTube-14857212f15256ff4dd0d36ff5158005f1d7caae.tar.zst
PeerTube-14857212f15256ff4dd0d36ff5158005f1d7caae.zip
Move b frame strategy in transcoding profile
We may use a too high value for some encoders and it allows to specify custom values/strategy
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r--server/helpers/ffmpeg-utils.ts18
1 files changed, 7 insertions, 11 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index ab29d4691..78ee5fa7f 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -287,8 +287,8 @@ async function getLiveTranscodingCommand (options: {
287 addDefaultEncoderParams({ command, encoder: builderResult.encoder, fps: resolutionFPS, streamNum: i }) 287 addDefaultEncoderParams({ command, encoder: builderResult.encoder, fps: resolutionFPS, streamNum: i })
288 288
289 logger.debug( 289 logger.debug(
290 'Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile, builderResult, 290 'Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile,
291 { fps: resolutionFPS, resolution, ...lTags() } 291 { builderResult, fps: resolutionFPS, resolution, ...lTags() }
292 ) 292 )
293 293
294 command.outputOption(`${buildStreamSuffix('-c:v', i)} ${builderResult.encoder}`) 294 command.outputOption(`${buildStreamSuffix('-c:v', i)} ${builderResult.encoder}`)
@@ -314,8 +314,8 @@ async function getLiveTranscodingCommand (options: {
314 addDefaultEncoderParams({ command, encoder: builderResult.encoder, fps: resolutionFPS, streamNum: i }) 314 addDefaultEncoderParams({ command, encoder: builderResult.encoder, fps: resolutionFPS, streamNum: i })
315 315
316 logger.debug( 316 logger.debug(
317 'Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult, 317 'Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile,
318 { fps: resolutionFPS, resolution, ...lTags() } 318 { builderResult, fps: resolutionFPS, resolution, ...lTags() }
319 ) 319 )
320 320
321 command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`) 321 command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`)
@@ -368,10 +368,6 @@ function addDefaultEncoderGlobalParams (options: {
368 command.outputOption('-max_muxing_queue_size 1024') 368 command.outputOption('-max_muxing_queue_size 1024')
369 // strip all metadata 369 // strip all metadata
370 .outputOption('-map_metadata -1') 370 .outputOption('-map_metadata -1')
371 // NOTE: b-strategy 1 - heuristic algorithm, 16 is optimal B-frames for it
372 .outputOption('-b_strategy 1')
373 // NOTE: Why 16: https://github.com/Chocobozzz/PeerTube/pull/774. b-strategy 2 -> B-frames<16
374 .outputOption('-bf 16')
375 // allows import of source material with incompatible pixel formats (e.g. MJPEG video) 371 // allows import of source material with incompatible pixel formats (e.g. MJPEG video)
376 .outputOption('-pix_fmt yuv420p') 372 .outputOption('-pix_fmt yuv420p')
377} 373}
@@ -627,8 +623,8 @@ async function presetVideo (options: {
627 623
628 logger.debug( 624 logger.debug(
629 'Apply ffmpeg params from %s for %s stream of input %s using %s profile.', 625 'Apply ffmpeg params from %s for %s stream of input %s using %s profile.',
630 builderResult.encoder, streamType, input, profile, builderResult, 626 builderResult.encoder, streamType, input, profile,
631 { resolution, fps, ...lTags() } 627 { builderResult, resolution, fps, ...lTags() }
632 ) 628 )
633 629
634 if (streamType === 'video') { 630 if (streamType === 'video') {
@@ -734,7 +730,7 @@ async function runCommand (options: {
734 command.on('start', cmdline => { shellCommand = cmdline }) 730 command.on('start', cmdline => { shellCommand = cmdline })
735 731
736 command.on('error', (err, stdout, stderr) => { 732 command.on('error', (err, stdout, stderr) => {
737 if (silent !== true) logger.error('Error in ffmpeg.', { stdout, stderr, ...lTags() }) 733 if (silent !== true) logger.error('Error in ffmpeg.', { stdout, stderr, shellCommand, ...lTags() })
738 734
739 rej(err) 735 rej(err)
740 }) 736 })