diff options
Diffstat (limited to 'server/lib/job-queue/handlers/video-transcoding.ts')
-rw-r--r-- | server/lib/job-queue/handlers/video-transcoding.ts | 30 |
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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { getVideoFilePath } from '@server/lib/video-paths' | ||
3 | import { MVideoFullLight, MVideoUUID, MVideoWithFile } from '@server/types/models' | ||
2 | import { | 4 | import { |
3 | MergeAudioTranscodingPayload, | 5 | MergeAudioTranscodingPayload, |
4 | NewResolutionTranscodingPayload, | 6 | NewResolutionTranscodingPayload, |
5 | OptimizeTranscodingPayload, | 7 | OptimizeTranscodingPayload, |
6 | VideoTranscodingPayload | 8 | VideoTranscodingPayload |
7 | } from '../../../../shared' | 9 | } from '../../../../shared' |
10 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | ||
11 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' | ||
8 | import { logger } from '../../../helpers/logger' | 12 | import { logger } from '../../../helpers/logger' |
13 | import { CONFIG } from '../../../initializers/config' | ||
14 | import { sequelizeTypescript } from '../../../initializers/database' | ||
9 | import { VideoModel } from '../../../models/video/video' | 15 | import { VideoModel } from '../../../models/video/video' |
10 | import { JobQueue } from '../job-queue' | ||
11 | import { federateVideoIfNeeded } from '../../activitypub/videos' | 16 | import { federateVideoIfNeeded } from '../../activitypub/videos' |
12 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | ||
13 | import { sequelizeTypescript } from '../../../initializers/database' | ||
14 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' | ||
15 | import { generateHlsPlaylist, mergeAudioVideofile, optimizeOriginalVideofile, transcodeNewResolution } from '../../video-transcoding' | ||
16 | import { Notifier } from '../../notifier' | 17 | import { Notifier } from '../../notifier' |
17 | import { CONFIG } from '../../../initializers/config' | 18 | import { generateHlsPlaylist, mergeAudioVideofile, optimizeOriginalVideofile, transcodeNewResolution } from '../../video-transcoding' |
18 | import { MVideoFullLight, MVideoUUID, MVideoWithFile } from '@server/types/models' | 19 | import { JobQueue } from '../job-queue' |
19 | 20 | ||
20 | async function processVideoTranscoding (job: Bull.Job) { | 21 | async 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') { |