diff options
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 268ed7624..3b794b8a2 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -353,7 +353,7 @@ function convertWebPToJPG (path: string, destination: string): Promise<void> { | |||
353 | }) | 353 | }) |
354 | } | 354 | } |
355 | 355 | ||
356 | function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: number[], deleteSegments: boolean) { | 356 | function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: number[], fps, deleteSegments: boolean) { |
357 | const command = getFFmpeg(rtmpUrl) | 357 | const command = getFFmpeg(rtmpUrl) |
358 | command.inputOption('-fflags nobuffer') | 358 | command.inputOption('-fflags nobuffer') |
359 | 359 | ||
@@ -375,10 +375,6 @@ function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: numb | |||
375 | })) | 375 | })) |
376 | ]) | 376 | ]) |
377 | 377 | ||
378 | const liveFPS = VIDEO_TRANSCODING_FPS.AVERAGE | ||
379 | |||
380 | command.withFps(liveFPS) | ||
381 | |||
382 | command.outputOption('-b_strategy 1') | 378 | command.outputOption('-b_strategy 1') |
383 | command.outputOption('-bf 16') | 379 | command.outputOption('-bf 16') |
384 | command.outputOption('-preset superfast') | 380 | command.outputOption('-preset superfast') |
@@ -386,13 +382,14 @@ function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: numb | |||
386 | command.outputOption('-map_metadata -1') | 382 | command.outputOption('-map_metadata -1') |
387 | command.outputOption('-pix_fmt yuv420p') | 383 | command.outputOption('-pix_fmt yuv420p') |
388 | command.outputOption('-max_muxing_queue_size 1024') | 384 | command.outputOption('-max_muxing_queue_size 1024') |
385 | command.outputOption('-g ' + (fps * 2)) | ||
389 | 386 | ||
390 | for (let i = 0; i < resolutions.length; i++) { | 387 | for (let i = 0; i < resolutions.length; i++) { |
391 | const resolution = resolutions[i] | 388 | const resolution = resolutions[i] |
392 | 389 | ||
393 | command.outputOption(`-map [vout${resolution}]`) | 390 | command.outputOption(`-map [vout${resolution}]`) |
394 | command.outputOption(`-c:v:${i} libx264`) | 391 | command.outputOption(`-c:v:${i} libx264`) |
395 | command.outputOption(`-b:v:${i} ${getTargetBitrate(resolution, liveFPS, VIDEO_TRANSCODING_FPS)}`) | 392 | command.outputOption(`-b:v:${i} ${getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS)}`) |
396 | 393 | ||
397 | command.outputOption(`-map a:0`) | 394 | command.outputOption(`-map a:0`) |
398 | command.outputOption(`-c:a:${i} aac`) | 395 | command.outputOption(`-c:a:${i} aac`) |
@@ -443,8 +440,8 @@ async function hlsPlaylistToFragmentedMP4 (hlsDirectory: string, segmentFiles: s | |||
443 | command.run() | 440 | command.run() |
444 | 441 | ||
445 | function cleaner () { | 442 | function cleaner () { |
446 | remove(concatFile) | 443 | remove(concatFilePath) |
447 | .catch(err => logger.error('Cannot remove concat file in %s.', hlsDirectory, { err })) | 444 | .catch(err => logger.error('Cannot remove concat file in %s.', hlsDirectory, { err })) |
448 | } | 445 | } |
449 | 446 | ||
450 | return new Promise<string>((res, rej) => { | 447 | return new Promise<string>((res, rej) => { |
@@ -497,7 +494,7 @@ function addDefaultX264Params (command: ffmpeg.FfmpegCommand) { | |||
497 | } | 494 | } |
498 | 495 | ||
499 | function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, deleteSegments: boolean) { | 496 | function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, deleteSegments: boolean) { |
500 | command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME) | 497 | command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS) |
501 | command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE) | 498 | command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE) |
502 | 499 | ||
503 | if (deleteSegments === true) { | 500 | if (deleteSegments === true) { |