diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-23 11:20:00 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-07-26 11:29:31 +0200 |
commit | 764b1a14fc494f2cfd7ea590d2f07b01df65c7ad (patch) | |
tree | 198ca5f242c63a205a05fa4cfd6d063277c541fd /server/helpers/ffmpeg-utils.ts | |
parent | 83903cb65d531a6b6b91715387493ba8312b264d (diff) | |
download | PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.tar.gz PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.tar.zst PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.zip |
Use random names for VOD HLS playlists
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index 6f5a71b4a..9ad4b7f3b 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -212,14 +212,17 @@ async function transcode (options: TranscodeOptions) { | |||
212 | 212 | ||
213 | async function getLiveTranscodingCommand (options: { | 213 | async function getLiveTranscodingCommand (options: { |
214 | rtmpUrl: string | 214 | rtmpUrl: string |
215 | |||
215 | outPath: string | 216 | outPath: string |
217 | masterPlaylistName: string | ||
218 | |||
216 | resolutions: number[] | 219 | resolutions: number[] |
217 | fps: number | 220 | fps: number |
218 | 221 | ||
219 | availableEncoders: AvailableEncoders | 222 | availableEncoders: AvailableEncoders |
220 | profile: string | 223 | profile: string |
221 | }) { | 224 | }) { |
222 | const { rtmpUrl, outPath, resolutions, fps, availableEncoders, profile } = options | 225 | const { rtmpUrl, outPath, resolutions, fps, availableEncoders, profile, masterPlaylistName } = options |
223 | const input = rtmpUrl | 226 | const input = rtmpUrl |
224 | 227 | ||
225 | const command = getFFmpeg(input, 'live') | 228 | const command = getFFmpeg(input, 'live') |
@@ -301,14 +304,14 @@ async function getLiveTranscodingCommand (options: { | |||
301 | 304 | ||
302 | command.complexFilter(complexFilter) | 305 | command.complexFilter(complexFilter) |
303 | 306 | ||
304 | addDefaultLiveHLSParams(command, outPath) | 307 | addDefaultLiveHLSParams(command, outPath, masterPlaylistName) |
305 | 308 | ||
306 | command.outputOption('-var_stream_map', varStreamMap.join(' ')) | 309 | command.outputOption('-var_stream_map', varStreamMap.join(' ')) |
307 | 310 | ||
308 | return command | 311 | return command |
309 | } | 312 | } |
310 | 313 | ||
311 | function getLiveMuxingCommand (rtmpUrl: string, outPath: string) { | 314 | function getLiveMuxingCommand (rtmpUrl: string, outPath: string, masterPlaylistName: string) { |
312 | const command = getFFmpeg(rtmpUrl, 'live') | 315 | const command = getFFmpeg(rtmpUrl, 'live') |
313 | 316 | ||
314 | command.outputOption('-c:v copy') | 317 | command.outputOption('-c:v copy') |
@@ -316,7 +319,7 @@ function getLiveMuxingCommand (rtmpUrl: string, outPath: string) { | |||
316 | command.outputOption('-map 0:a?') | 319 | command.outputOption('-map 0:a?') |
317 | command.outputOption('-map 0:v?') | 320 | command.outputOption('-map 0:v?') |
318 | 321 | ||
319 | addDefaultLiveHLSParams(command, outPath) | 322 | addDefaultLiveHLSParams(command, outPath, masterPlaylistName) |
320 | 323 | ||
321 | return command | 324 | return command |
322 | } | 325 | } |
@@ -371,12 +374,12 @@ function addDefaultEncoderParams (options: { | |||
371 | } | 374 | } |
372 | } | 375 | } |
373 | 376 | ||
374 | function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string) { | 377 | function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, masterPlaylistName: string) { |
375 | command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS) | 378 | command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS) |
376 | command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE) | 379 | command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE) |
377 | command.outputOption('-hls_flags delete_segments+independent_segments') | 380 | command.outputOption('-hls_flags delete_segments+independent_segments') |
378 | command.outputOption(`-hls_segment_filename ${join(outPath, '%v-%06d.ts')}`) | 381 | command.outputOption(`-hls_segment_filename ${join(outPath, '%v-%06d.ts')}`) |
379 | command.outputOption('-master_pl_name master.m3u8') | 382 | command.outputOption('-master_pl_name ' + masterPlaylistName) |
380 | command.outputOption(`-f hls`) | 383 | command.outputOption(`-f hls`) |
381 | 384 | ||
382 | command.output(join(outPath, '%v.m3u8')) | 385 | command.output(join(outPath, '%v.m3u8')) |