diff options
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index fac2595f1..b25dcaa90 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -5,7 +5,7 @@ import { VideoFileMetadata } from '@shared/models/videos/video-file-metadata' | |||
5 | import { getMaxBitrate, getTargetBitrate, VideoResolution } from '../../shared/models/videos' | 5 | import { getMaxBitrate, getTargetBitrate, VideoResolution } from '../../shared/models/videos' |
6 | import { checkFFmpegEncoders } from '../initializers/checker-before-init' | 6 | import { checkFFmpegEncoders } from '../initializers/checker-before-init' |
7 | import { CONFIG } from '../initializers/config' | 7 | import { CONFIG } from '../initializers/config' |
8 | import { FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants' | 8 | import { FFMPEG_NICE, VIDEO_LIVE, VIDEO_TRANSCODING_FPS } from '../initializers/constants' |
9 | import { processImage } from './image-utils' | 9 | import { processImage } from './image-utils' |
10 | import { logger } from './logger' | 10 | import { logger } from './logger' |
11 | 11 | ||
@@ -353,7 +353,7 @@ function convertWebPToJPG (path: string, destination: string): Promise<void> { | |||
353 | }) | 353 | }) |
354 | } | 354 | } |
355 | 355 | ||
356 | function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: number[]) { | 356 | function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: number[], deleteSegments: boolean) { |
357 | const command = getFFmpeg(rtmpUrl) | 357 | const command = getFFmpeg(rtmpUrl) |
358 | command.inputOption('-fflags nobuffer') | 358 | command.inputOption('-fflags nobuffer') |
359 | 359 | ||
@@ -399,7 +399,7 @@ function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: numb | |||
399 | varStreamMap.push(`v:${i},a:${i}`) | 399 | varStreamMap.push(`v:${i},a:${i}`) |
400 | } | 400 | } |
401 | 401 | ||
402 | addDefaultLiveHLSParams(command, outPath) | 402 | addDefaultLiveHLSParams(command, outPath, deleteSegments) |
403 | 403 | ||
404 | command.outputOption('-var_stream_map', varStreamMap.join(' ')) | 404 | command.outputOption('-var_stream_map', varStreamMap.join(' ')) |
405 | 405 | ||
@@ -408,7 +408,7 @@ function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: numb | |||
408 | return command | 408 | return command |
409 | } | 409 | } |
410 | 410 | ||
411 | function runLiveMuxing (rtmpUrl: string, outPath: string) { | 411 | function runLiveMuxing (rtmpUrl: string, outPath: string, deleteSegments: boolean) { |
412 | const command = getFFmpeg(rtmpUrl) | 412 | const command = getFFmpeg(rtmpUrl) |
413 | command.inputOption('-fflags nobuffer') | 413 | command.inputOption('-fflags nobuffer') |
414 | 414 | ||
@@ -417,7 +417,7 @@ function runLiveMuxing (rtmpUrl: string, outPath: string) { | |||
417 | command.outputOption('-map 0:a?') | 417 | command.outputOption('-map 0:a?') |
418 | command.outputOption('-map 0:v?') | 418 | command.outputOption('-map 0:v?') |
419 | 419 | ||
420 | addDefaultLiveHLSParams(command, outPath) | 420 | addDefaultLiveHLSParams(command, outPath, deleteSegments) |
421 | 421 | ||
422 | command.run() | 422 | command.run() |
423 | 423 | ||
@@ -457,10 +457,14 @@ function addDefaultX264Params (command: ffmpeg.FfmpegCommand) { | |||
457 | .outputOption('-map_metadata -1') // strip all metadata | 457 | .outputOption('-map_metadata -1') // strip all metadata |
458 | } | 458 | } |
459 | 459 | ||
460 | function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string) { | 460 | function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, deleteSegments: boolean) { |
461 | command.outputOption('-hls_time 4') | 461 | command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME) |
462 | command.outputOption('-hls_list_size 15') | 462 | command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE) |
463 | command.outputOption('-hls_flags delete_segments') | 463 | |
464 | if (deleteSegments === true) { | ||
465 | command.outputOption('-hls_flags delete_segments') | ||
466 | } | ||
467 | |||
464 | command.outputOption(`-hls_segment_filename ${join(outPath, '%v-%d.ts')}`) | 468 | command.outputOption(`-hls_segment_filename ${join(outPath, '%v-%d.ts')}`) |
465 | command.outputOption('-master_pl_name master.m3u8') | 469 | command.outputOption('-master_pl_name master.m3u8') |
466 | command.outputOption(`-f hls`) | 470 | command.outputOption(`-f hls`) |