aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/video.ts')
-rw-r--r--server/lib/video.ts37
1 files changed, 28 insertions, 9 deletions
diff --git a/server/lib/video.ts b/server/lib/video.ts
index ec4256c1a..a98e45c60 100644
--- a/server/lib/video.ts
+++ b/server/lib/video.ts
@@ -6,7 +6,7 @@ import { VideoModel } from '@server/models/video/video'
6import { VideoJobInfoModel } from '@server/models/video/video-job-info' 6import { VideoJobInfoModel } from '@server/models/video/video-job-info'
7import { FilteredModelAttributes } from '@server/types' 7import { FilteredModelAttributes } from '@server/types'
8import { MThumbnail, MUserId, MVideoFile, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models' 8import { MThumbnail, MUserId, MVideoFile, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models'
9import { ThumbnailType, VideoCreate, VideoPrivacy, VideoTranscodingPayload } from '@shared/models' 9import { ThumbnailType, VideoCreate, VideoPrivacy, VideoState, VideoTranscodingPayload } from '@shared/models'
10import { CreateJobOptions, JobQueue } from './job-queue/job-queue' 10import { CreateJobOptions, JobQueue } from './job-queue/job-queue'
11import { updateVideoMiniatureFromExisting } from './thumbnail' 11import { updateVideoMiniatureFromExisting } from './thumbnail'
12import { CONFIG } from '@server/initializers/config' 12import { CONFIG } from '@server/initializers/config'
@@ -67,6 +67,8 @@ async function buildVideoThumbnailsFromReq (options: {
67 return Promise.all(promises) 67 return Promise.all(promises)
68} 68}
69 69
70// ---------------------------------------------------------------------------
71
70async function setVideoTags (options: { 72async function setVideoTags (options: {
71 video: MVideoTag 73 video: MVideoTag
72 tags: string[] 74 tags: string[]
@@ -81,7 +83,16 @@ async function setVideoTags (options: {
81 video.Tags = tagInstances 83 video.Tags = tagInstances
82} 84}
83 85
84async function addOptimizeOrMergeAudioJob (video: MVideoUUID, videoFile: MVideoFile, user: MUserId, isNewVideo = true) { 86// ---------------------------------------------------------------------------
87
88async function addOptimizeOrMergeAudioJob (options: {
89 video: MVideoUUID
90 videoFile: MVideoFile
91 user: MUserId
92 isNewVideo?: boolean // Default true
93}) {
94 const { video, videoFile, user, isNewVideo } = options
95
85 let dataInput: VideoTranscodingPayload 96 let dataInput: VideoTranscodingPayload
86 97
87 if (videoFile.isAudio()) { 98 if (videoFile.isAudio()) {
@@ -113,13 +124,6 @@ async function addTranscodingJob (payload: VideoTranscodingPayload, options: Cre
113 return JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: payload }, options) 124 return JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: payload }, options)
114} 125}
115 126
116async function addMoveToObjectStorageJob (video: MVideoUUID, isNewVideo = true) {
117 await VideoJobInfoModel.increaseOrCreate(video.uuid, 'pendingMove')
118
119 const dataInput = { videoUUID: video.uuid, isNewVideo }
120 return JobQueue.Instance.createJobWithPromise({ type: 'move-to-object-storage', payload: dataInput })
121}
122
123async function getTranscodingJobPriority (user: MUserId) { 127async function getTranscodingJobPriority (user: MUserId) {
124 const now = new Date() 128 const now = new Date()
125 const lastWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7) 129 const lastWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7)
@@ -131,6 +135,21 @@ async function getTranscodingJobPriority (user: MUserId) {
131 135
132// --------------------------------------------------------------------------- 136// ---------------------------------------------------------------------------
133 137
138async function addMoveToObjectStorageJob (options: {
139 video: MVideoUUID
140 previousVideoState: VideoState
141 isNewVideo?: boolean // Default true
142}) {
143 const { video, previousVideoState, isNewVideo = true } = options
144
145 await VideoJobInfoModel.increaseOrCreate(video.uuid, 'pendingMove')
146
147 const dataInput = { videoUUID: video.uuid, isNewVideo, previousVideoState }
148 return JobQueue.Instance.createJobWithPromise({ type: 'move-to-object-storage', payload: dataInput })
149}
150
151// ---------------------------------------------------------------------------
152
134export { 153export {
135 buildLocalVideoFromReq, 154 buildLocalVideoFromReq,
136 buildVideoThumbnailsFromReq, 155 buildVideoThumbnailsFromReq,