aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/ffmpeg-utils.ts15
-rw-r--r--server/helpers/video.ts10
2 files changed, 15 insertions, 10 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index 268ed7624..3b794b8a2 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -353,7 +353,7 @@ function convertWebPToJPG (path: string, destination: string): Promise<void> {
353 }) 353 })
354} 354}
355 355
356function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: number[], deleteSegments: boolean) { 356function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: number[], fps, deleteSegments: boolean) {
357 const command = getFFmpeg(rtmpUrl) 357 const command = getFFmpeg(rtmpUrl)
358 command.inputOption('-fflags nobuffer') 358 command.inputOption('-fflags nobuffer')
359 359
@@ -375,10 +375,6 @@ function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: numb
375 })) 375 }))
376 ]) 376 ])
377 377
378 const liveFPS = VIDEO_TRANSCODING_FPS.AVERAGE
379
380 command.withFps(liveFPS)
381
382 command.outputOption('-b_strategy 1') 378 command.outputOption('-b_strategy 1')
383 command.outputOption('-bf 16') 379 command.outputOption('-bf 16')
384 command.outputOption('-preset superfast') 380 command.outputOption('-preset superfast')
@@ -386,13 +382,14 @@ function runLiveTranscoding (rtmpUrl: string, outPath: string, resolutions: numb
386 command.outputOption('-map_metadata -1') 382 command.outputOption('-map_metadata -1')
387 command.outputOption('-pix_fmt yuv420p') 383 command.outputOption('-pix_fmt yuv420p')
388 command.outputOption('-max_muxing_queue_size 1024') 384 command.outputOption('-max_muxing_queue_size 1024')
385 command.outputOption('-g ' + (fps * 2))
389 386
390 for (let i = 0; i < resolutions.length; i++) { 387 for (let i = 0; i < resolutions.length; i++) {
391 const resolution = resolutions[i] 388 const resolution = resolutions[i]
392 389
393 command.outputOption(`-map [vout${resolution}]`) 390 command.outputOption(`-map [vout${resolution}]`)
394 command.outputOption(`-c:v:${i} libx264`) 391 command.outputOption(`-c:v:${i} libx264`)
395 command.outputOption(`-b:v:${i} ${getTargetBitrate(resolution, liveFPS, VIDEO_TRANSCODING_FPS)}`) 392 command.outputOption(`-b:v:${i} ${getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS)}`)
396 393
397 command.outputOption(`-map a:0`) 394 command.outputOption(`-map a:0`)
398 command.outputOption(`-c:a:${i} aac`) 395 command.outputOption(`-c:a:${i} aac`)
@@ -443,8 +440,8 @@ async function hlsPlaylistToFragmentedMP4 (hlsDirectory: string, segmentFiles: s
443 command.run() 440 command.run()
444 441
445 function cleaner () { 442 function cleaner () {
446 remove(concatFile) 443 remove(concatFilePath)
447 .catch(err => logger.error('Cannot remove concat file in %s.', hlsDirectory, { err })) 444 .catch(err => logger.error('Cannot remove concat file in %s.', hlsDirectory, { err }))
448 } 445 }
449 446
450 return new Promise<string>((res, rej) => { 447 return new Promise<string>((res, rej) => {
@@ -497,7 +494,7 @@ function addDefaultX264Params (command: ffmpeg.FfmpegCommand) {
497} 494}
498 495
499function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, deleteSegments: boolean) { 496function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, deleteSegments: boolean) {
500 command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME) 497 command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS)
501 command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE) 498 command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE)
502 499
503 if (deleteSegments === true) { 500 if (deleteSegments === true) {
diff --git a/server/helpers/video.ts b/server/helpers/video.ts
index 488b4da17..999137c6d 100644
--- a/server/helpers/video.ts
+++ b/server/helpers/video.ts
@@ -15,7 +15,7 @@ import {
15 MVideoThumbnail, 15 MVideoThumbnail,
16 MVideoWithRights 16 MVideoWithRights
17} from '@server/types/models' 17} from '@server/types/models'
18import { VideoPrivacy, VideoTranscodingPayload } from '@shared/models' 18import { VideoPrivacy, VideoState, VideoTranscodingPayload } from '@shared/models'
19import { VideoModel } from '../models/video/video' 19import { VideoModel } from '../models/video/video'
20 20
21type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' 21type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes'
@@ -104,6 +104,13 @@ function isPrivacyForFederation (privacy: VideoPrivacy) {
104 (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true && castedPrivacy === VideoPrivacy.UNLISTED) 104 (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true && castedPrivacy === VideoPrivacy.UNLISTED)
105} 105}
106 106
107function isStateForFederation (state: VideoState) {
108 const castedState = parseInt(state + '', 10)
109
110 return castedState === VideoState.PUBLISHED || castedState === VideoState.WAITING_FOR_LIVE || castedState === VideoState.LIVE_ENDED
111
112}
113
107function getPrivaciesForFederation () { 114function getPrivaciesForFederation () {
108 return (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true) 115 return (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true)
109 ? [ { privacy: VideoPrivacy.PUBLIC }, { privacy: VideoPrivacy.UNLISTED } ] 116 ? [ { privacy: VideoPrivacy.PUBLIC }, { privacy: VideoPrivacy.UNLISTED } ]
@@ -127,6 +134,7 @@ export {
127 addOptimizeOrMergeAudioJob, 134 addOptimizeOrMergeAudioJob,
128 extractVideo, 135 extractVideo,
129 getExtFromMimetype, 136 getExtFromMimetype,
137 isStateForFederation,
130 isPrivacyForFederation, 138 isPrivacyForFederation,
131 getPrivaciesForFederation 139 getPrivaciesForFederation
132} 140}