aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/video-transcoding.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-10-26 16:44:23 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitb5b687550d8ef8beafdf706e45d6556fb5f4c876 (patch)
tree232412d463c78af1f7ab5797db5aecf1096d08da /server/lib/job-queue/handlers/video-transcoding.ts
parentef680f68351ec10ab73a1131570a6d14ce14c195 (diff)
downloadPeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.tar.gz
PeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.tar.zst
PeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.zip
Add ability to save live replay
Diffstat (limited to 'server/lib/job-queue/handlers/video-transcoding.ts')
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts30
1 files changed, 22 insertions, 8 deletions
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 6659ab716..2aebc29f7 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -1,21 +1,22 @@
1import * as Bull from 'bull' 1import * as Bull from 'bull'
2import { getVideoFilePath } from '@server/lib/video-paths'
3import { MVideoFullLight, MVideoUUID, MVideoWithFile } from '@server/types/models'
2import { 4import {
3 MergeAudioTranscodingPayload, 5 MergeAudioTranscodingPayload,
4 NewResolutionTranscodingPayload, 6 NewResolutionTranscodingPayload,
5 OptimizeTranscodingPayload, 7 OptimizeTranscodingPayload,
6 VideoTranscodingPayload 8 VideoTranscodingPayload
7} from '../../../../shared' 9} from '../../../../shared'
10import { retryTransactionWrapper } from '../../../helpers/database-utils'
11import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils'
8import { logger } from '../../../helpers/logger' 12import { logger } from '../../../helpers/logger'
13import { CONFIG } from '../../../initializers/config'
14import { sequelizeTypescript } from '../../../initializers/database'
9import { VideoModel } from '../../../models/video/video' 15import { VideoModel } from '../../../models/video/video'
10import { JobQueue } from '../job-queue'
11import { federateVideoIfNeeded } from '../../activitypub/videos' 16import { federateVideoIfNeeded } from '../../activitypub/videos'
12import { retryTransactionWrapper } from '../../../helpers/database-utils'
13import { sequelizeTypescript } from '../../../initializers/database'
14import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils'
15import { generateHlsPlaylist, mergeAudioVideofile, optimizeOriginalVideofile, transcodeNewResolution } from '../../video-transcoding'
16import { Notifier } from '../../notifier' 17import { Notifier } from '../../notifier'
17import { CONFIG } from '../../../initializers/config' 18import { generateHlsPlaylist, mergeAudioVideofile, optimizeOriginalVideofile, transcodeNewResolution } from '../../video-transcoding'
18import { MVideoFullLight, MVideoUUID, MVideoWithFile } from '@server/types/models' 19import { JobQueue } from '../job-queue'
19 20
20async function processVideoTranscoding (job: Bull.Job) { 21async function processVideoTranscoding (job: Bull.Job) {
21 const payload = job.data as VideoTranscodingPayload 22 const payload = job.data as VideoTranscodingPayload
@@ -29,7 +30,20 @@ async function processVideoTranscoding (job: Bull.Job) {
29 } 30 }
30 31
31 if (payload.type === 'hls') { 32 if (payload.type === 'hls') {
32 await generateHlsPlaylist(video, payload.resolution, payload.copyCodecs, payload.isPortraitMode || false) 33 const videoFileInput = payload.copyCodecs
34 ? video.getWebTorrentFile(payload.resolution)
35 : video.getMaxQualityFile()
36
37 const videoOrStreamingPlaylist = videoFileInput.getVideoOrStreamingPlaylist()
38 const videoInputPath = getVideoFilePath(videoOrStreamingPlaylist, videoFileInput)
39
40 await generateHlsPlaylist({
41 video,
42 videoInputPath,
43 resolution: payload.resolution,
44 copyCodecs: payload.copyCodecs,
45 isPortraitMode: payload.isPortraitMode || false
46 })
33 47
34 await retryTransactionWrapper(onHlsPlaylistGenerationSuccess, video) 48 await retryTransactionWrapper(onHlsPlaylistGenerationSuccess, video)
35 } else if (payload.type === 'new-resolution') { 49 } else if (payload.type === 'new-resolution') {