X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fffmpeg-utils.ts;h=bf6408d3e1c63b116c239b779b0622f47209766e;hb=040d6896a3cd5622e78cccdedd8cce2afcf49a31;hp=0aadf694ed5689e2b69f6ecb1423207dd14fd97f;hpb=55223d65744daf74407fb6a21873aa11019c8d15;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 0aadf694e..bf6408d3e 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -137,6 +137,8 @@ interface HLSTranscodeOptions extends BaseTranscodeOptions { interface HLSFromTSTranscodeOptions extends BaseTranscodeOptions { type: 'hls-from-ts' + isAAC: boolean + hlsPlaylist: { videoFilename: string } @@ -208,7 +210,6 @@ async function getLiveTranscodingCommand (options: { const input = rtmpUrl const command = getFFmpeg(input, 'live') - command.inputOption('-fflags nobuffer') const varStreamMap: string[] = [] @@ -229,6 +230,7 @@ async function getLiveTranscodingCommand (options: { ]) command.outputOption('-preset superfast') + command.outputOption('-sc_threshold 0') addDefaultEncoderGlobalParams({ command }) @@ -290,7 +292,6 @@ async function getLiveTranscodingCommand (options: { function getLiveMuxingCommand (rtmpUrl: string, outPath: string) { const command = getFFmpeg(rtmpUrl, 'live') - command.inputOption('-fflags nobuffer') command.outputOption('-c:v copy') command.outputOption('-c:a copy') @@ -371,7 +372,7 @@ function addDefaultEncoderParams (options: { function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string) { command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS) command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE) - command.outputOption('-hls_flags delete_segments') + command.outputOption('-hls_flags delete_segments+independent_segments') command.outputOption(`-hls_segment_filename ${join(outPath, '%v-%06d.ts')}`) command.outputOption('-master_pl_name master.m3u8') command.outputOption(`-f hls`) @@ -456,11 +457,13 @@ async function buildHLSVODCommand (command: ffmpeg.FfmpegCommand, options: HLSTr async function buildHLSVODFromTSCommand (command: ffmpeg.FfmpegCommand, options: HLSFromTSTranscodeOptions) { const videoPath = getHLSVideoPath(options) - command.inputOption('-safe 0') - command.inputOption('-f concat') + command.outputOption('-c copy') - command.outputOption('-c:v copy') - command.audioFilter('aresample=async=1:first_pts=0') + if (options.isAAC) { + // Required for example when copying an AAC stream from an MPEG-TS + // Since it's a bitstream filter, we don't need to reencode the audio + command.outputOption('-bsf:a aac_adtstoasc') + } addCommonHLSVODCommandOptions(command, videoPath)