X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fffmpeg-utils.ts;h=3b794b8a29144167f996ea4b237536d6b5633dc6;hb=bd54ad1953ee0484ba90cf5f588f4c282048f368;hp=b063cedcb33c7dd013367762d45a7f1497fd10f6;hpb=31c82cd914e13dbf53280d0aad0740d70c414441;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index b063cedcb..3b794b8a2 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -8,7 +8,6 @@ import { CONFIG } from '../initializers/config' import { FFMPEG_NICE, VIDEO_LIVE, VIDEO_TRANSCODING_FPS } from '../initializers/constants' import { processImage } from './image-utils' import { logger } from './logger' -import { concat } from 'lodash' /** * A toolbox to play with audio @@ -354,7 +353,7 @@ function convertWebPToJPG (path: string, destination: string): Promise { }) } -function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: number[], deleteSegments: boolean) { +function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: number[], fps, deleteSegments: boolean) { const command = getFFmpeg(rtmpUrl) command.inputOption('-fflags nobuffer') @@ -376,23 +375,21 @@ function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: numb })) ]) - const liveFPS = VIDEO_TRANSCODING_FPS.AVERAGE - - command.withFps(liveFPS) - command.outputOption('-b_strategy 1') command.outputOption('-bf 16') command.outputOption('-preset superfast') command.outputOption('-level 3.1') command.outputOption('-map_metadata -1') command.outputOption('-pix_fmt yuv420p') + command.outputOption('-max_muxing_queue_size 1024') + command.outputOption('-g ' + (fps * 2)) for (let i = 0; i < resolutions.length; i++) { const resolution = resolutions[i] command.outputOption(`-map [vout${resolution}]`) command.outputOption(`-c:v:${i} libx264`) - command.outputOption(`-b:v:${i} ${getTargetBitrate(resolution, liveFPS, VIDEO_TRANSCODING_FPS)}`) + command.outputOption(`-b:v:${i} ${getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS)}`) command.outputOption(`-map a:0`) command.outputOption(`-c:a:${i} aac`) @@ -443,8 +440,8 @@ async function hlsPlaylistToFragmentedMP4 (hlsDirectory: string, segmentFiles: s command.run() function cleaner () { - remove(concatFile) - .catch(err => logger.error('Cannot remove concat file in %s.', hlsDirectory, { err })) + remove(concatFilePath) + .catch(err => logger.error('Cannot remove concat file in %s.', hlsDirectory, { err })) } return new Promise((res, rej) => { @@ -497,7 +494,7 @@ function addDefaultX264Params (command: ffmpeg.FfmpegCommand) { } function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, deleteSegments: boolean) { - command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME) + command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS) command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE) if (deleteSegments === true) {