1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Correctly handle RTMP streams without audio

This commit is contained in:
Chocobozzz 2022-09-28 10:23:03 +02:00
parent 690bad52e1
commit 1ce4256a65
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 43 additions and 17 deletions

View file

@ -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)