aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-12-04 10:02:02 +0100
committerChocobozzz <me@florianbigard.com>2020-12-04 10:02:09 +0100
commit55223d65744daf74407fb6a21873aa11019c8d15 (patch)
tree19c8b0b4222115d50c9a0d76492611330d323bca /server/helpers
parent312644ce3a59fcc10cc08d422081ebacfa14eec7 (diff)
downloadPeerTube-55223d65744daf74407fb6a21873aa11019c8d15.tar.gz
PeerTube-55223d65744daf74407fb6a21873aa11019c8d15.tar.zst
PeerTube-55223d65744daf74407fb6a21873aa11019c8d15.zip
Fix live transcoding threads config
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/ffmpeg-utils.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index c6b8a0eb0..0aadf694e 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -181,7 +181,7 @@ const builders: {
181async function transcode (options: TranscodeOptions) { 181async function transcode (options: TranscodeOptions) {
182 logger.debug('Will run transcode.', { options }) 182 logger.debug('Will run transcode.', { options })
183 183
184 let command = getFFmpeg(options.inputPath) 184 let command = getFFmpeg(options.inputPath, 'vod')
185 .output(options.outputPath) 185 .output(options.outputPath)
186 186
187 command = await builders[options.type](command, options) 187 command = await builders[options.type](command, options)
@@ -207,7 +207,7 @@ async function getLiveTranscodingCommand (options: {
207 const { rtmpUrl, outPath, resolutions, fps, availableEncoders, profile } = options 207 const { rtmpUrl, outPath, resolutions, fps, availableEncoders, profile } = options
208 const input = rtmpUrl 208 const input = rtmpUrl
209 209
210 const command = getFFmpeg(input) 210 const command = getFFmpeg(input, 'live')
211 command.inputOption('-fflags nobuffer') 211 command.inputOption('-fflags nobuffer')
212 212
213 const varStreamMap: string[] = [] 213 const varStreamMap: string[] = []
@@ -289,7 +289,7 @@ async function getLiveTranscodingCommand (options: {
289} 289}
290 290
291function getLiveMuxingCommand (rtmpUrl: string, outPath: string) { 291function getLiveMuxingCommand (rtmpUrl: string, outPath: string) {
292 const command = getFFmpeg(rtmpUrl) 292 const command = getFFmpeg(rtmpUrl, 'live')
293 command.inputOption('-fflags nobuffer') 293 command.inputOption('-fflags nobuffer')
294 294
295 command.outputOption('-c:v copy') 295 command.outputOption('-c:v copy')
@@ -605,13 +605,17 @@ function presetOnlyAudio (command: ffmpeg.FfmpegCommand): ffmpeg.FfmpegCommand {
605// Utils 605// Utils
606// --------------------------------------------------------------------------- 606// ---------------------------------------------------------------------------
607 607
608function getFFmpeg (input: string) { 608function getFFmpeg (input: string, type: 'live' | 'vod') {
609 // We set cwd explicitly because ffmpeg appears to create temporary files when trancoding which fails in read-only file systems 609 // We set cwd explicitly because ffmpeg appears to create temporary files when trancoding which fails in read-only file systems
610 const command = ffmpeg(input, { niceness: FFMPEG_NICE.TRANSCODING, cwd: CONFIG.STORAGE.TMP_DIR }) 610 const command = ffmpeg(input, { niceness: FFMPEG_NICE.TRANSCODING, cwd: CONFIG.STORAGE.TMP_DIR })
611 611
612 if (CONFIG.TRANSCODING.THREADS > 0) { 612 const threads = type === 'live'
613 ? CONFIG.LIVE.TRANSCODING.THREADS
614 : CONFIG.TRANSCODING.THREADS
615
616 if (threads > 0) {
613 // If we don't set any threads ffmpeg will chose automatically 617 // If we don't set any threads ffmpeg will chose automatically
614 command.outputOption('-threads ' + CONFIG.TRANSCODING.THREADS) 618 command.outputOption('-threads ' + threads)
615 } 619 }
616 620
617 return command 621 return command