X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fffmpeg%2Fffmpeg-live.ts;h=379d7b1ad5b532b72162bd6eb4801aa2b4351cfb;hb=b1dbb9fefc870a90b25f5c0153589f45c9e75e3e;hp=8377dc7e25435f72d72204e813d8afcf8d4092de;hpb=ffcfb32b2f593be46120b9e5fd16d6f8741d8ddc;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/ffmpeg/ffmpeg-live.ts b/server/helpers/ffmpeg/ffmpeg-live.ts index 8377dc7e2..379d7b1ad 100644 --- a/server/helpers/ffmpeg/ffmpeg-live.ts +++ b/server/helpers/ffmpeg/ffmpeg-live.ts @@ -23,11 +23,24 @@ async function getLiveTranscodingCommand (options: { fps: number bitrate: number ratio: number + hasAudio: boolean availableEncoders: AvailableEncoders profile: string }) { - const { inputUrl, outPath, resolutions, fps, bitrate, availableEncoders, profile, masterPlaylistName, ratio, latencyMode } = options + const { + inputUrl, + outPath, + resolutions, + fps, + bitrate, + availableEncoders, + profile, + masterPlaylistName, + ratio, + latencyMode, + hasAudio + } = options const command = getFFmpeg(inputUrl, 'live') @@ -47,6 +60,7 @@ async function getLiveTranscodingCommand (options: { addDefaultEncoderGlobalParams(command) for (let i = 0; i < resolutions.length; i++) { + const streamMap: string[] = [] const resolution = resolutions[i] const resolutionFPS = computeFPS(fps, resolution) @@ -94,9 +108,11 @@ async function getLiveTranscodingCommand (options: { options: `w=-2:h=${resolution}`, outputs: `vout${resolution}` }) + + streamMap.push(`v:${i}`) } - { + if (hasAudio) { const streamType: StreamType = 'audio' const builderResult = await getEncoderBuilderResult({ ...baseEncoderBuilderParams, streamType }) if (!builderResult) { @@ -114,9 +130,11 @@ async function getLiveTranscodingCommand (options: { command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`) applyEncoderOptions(command, builderResult.result) + + streamMap.push(`a:${i}`) } - varStreamMap.push(`v:${i},a:${i}`) + varStreamMap.push(streamMap.join(',')) } command.complexFilter(complexFilter)