aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/ffmpeg-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r--server/helpers/ffmpeg-utils.ts23
1 files changed, 9 insertions, 14 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index 7c997877c..085635b5a 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -190,12 +190,11 @@ async function getLiveTranscodingCommand (options: {
190 outPath: string 190 outPath: string
191 resolutions: number[] 191 resolutions: number[]
192 fps: number 192 fps: number
193 deleteSegments: boolean
194 193
195 availableEncoders: AvailableEncoders 194 availableEncoders: AvailableEncoders
196 profile: string 195 profile: string
197}) { 196}) {
198 const { rtmpUrl, outPath, resolutions, fps, deleteSegments, availableEncoders, profile } = options 197 const { rtmpUrl, outPath, resolutions, fps, availableEncoders, profile } = options
199 const input = rtmpUrl 198 const input = rtmpUrl
200 199
201 const command = getFFmpeg(input) 200 const command = getFFmpeg(input)
@@ -272,14 +271,14 @@ async function getLiveTranscodingCommand (options: {
272 varStreamMap.push(`v:${i},a:${i}`) 271 varStreamMap.push(`v:${i},a:${i}`)
273 } 272 }
274 273
275 addDefaultLiveHLSParams(command, outPath, deleteSegments) 274 addDefaultLiveHLSParams(command, outPath)
276 275
277 command.outputOption('-var_stream_map', varStreamMap.join(' ')) 276 command.outputOption('-var_stream_map', varStreamMap.join(' '))
278 277
279 return command 278 return command
280} 279}
281 280
282function getLiveMuxingCommand (rtmpUrl: string, outPath: string, deleteSegments: boolean) { 281function getLiveMuxingCommand (rtmpUrl: string, outPath: string) {
283 const command = getFFmpeg(rtmpUrl) 282 const command = getFFmpeg(rtmpUrl)
284 command.inputOption('-fflags nobuffer') 283 command.inputOption('-fflags nobuffer')
285 284
@@ -288,17 +287,17 @@ function getLiveMuxingCommand (rtmpUrl: string, outPath: string, deleteSegments:
288 command.outputOption('-map 0:a?') 287 command.outputOption('-map 0:a?')
289 command.outputOption('-map 0:v?') 288 command.outputOption('-map 0:v?')
290 289
291 addDefaultLiveHLSParams(command, outPath, deleteSegments) 290 addDefaultLiveHLSParams(command, outPath)
292 291
293 return command 292 return command
294} 293}
295 294
296async function hlsPlaylistToFragmentedMP4 (hlsDirectory: string, segmentFiles: string[], outputPath: string) { 295async function hlsPlaylistToFragmentedMP4 (replayDirectory: string, segmentFiles: string[], outputPath: string) {
297 const concatFilePath = join(hlsDirectory, 'concat.txt') 296 const concatFilePath = join(replayDirectory, 'concat.txt')
298 297
299 function cleaner () { 298 function cleaner () {
300 remove(concatFilePath) 299 remove(concatFilePath)
301 .catch(err => logger.error('Cannot remove concat file in %s.', hlsDirectory, { err })) 300 .catch(err => logger.error('Cannot remove concat file in %s.', replayDirectory, { err }))
302 } 301 }
303 302
304 // First concat the ts files to a mp4 file 303 // First concat the ts files to a mp4 file
@@ -385,14 +384,10 @@ function addDefaultEncoderParams (options: {
385 } 384 }
386} 385}
387 386
388function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, deleteSegments: boolean) { 387function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string) {
389 command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS) 388 command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS)
390 command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE) 389 command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE)
391 390 command.outputOption('-hls_flags delete_segments')
392 if (deleteSegments === true) {
393 command.outputOption('-hls_flags delete_segments')
394 }
395
396 command.outputOption(`-hls_segment_filename ${join(outPath, '%v-%06d.ts')}`) 391 command.outputOption(`-hls_segment_filename ${join(outPath, '%v-%06d.ts')}`)
397 command.outputOption('-master_pl_name master.m3u8') 392 command.outputOption('-master_pl_name master.m3u8')
398 command.outputOption(`-f hls`) 393 command.outputOption(`-f hls`)