aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/transcoding
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/transcoding')
-rw-r--r--server/lib/transcoding/create-transcoding-job.ts2
-rw-r--r--server/lib/transcoding/shared/job-builders/abstract-job-builder.ts2
-rw-r--r--server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts40
-rw-r--r--server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts4
-rw-r--r--server/lib/transcoding/web-transcoding.ts24
5 files changed, 36 insertions, 36 deletions
diff --git a/server/lib/transcoding/create-transcoding-job.ts b/server/lib/transcoding/create-transcoding-job.ts
index abe32684d..d78e68b87 100644
--- a/server/lib/transcoding/create-transcoding-job.ts
+++ b/server/lib/transcoding/create-transcoding-job.ts
@@ -15,7 +15,7 @@ export function createOptimizeOrMergeAudioJobs (options: {
15// --------------------------------------------------------------------------- 15// ---------------------------------------------------------------------------
16 16
17export function createTranscodingJobs (options: { 17export function createTranscodingJobs (options: {
18 transcodingType: 'hls' | 'webtorrent' 18 transcodingType: 'hls' | 'webtorrent' | 'web-video' // TODO: remove webtorrent in v7
19 video: MVideoFullLight 19 video: MVideoFullLight
20 resolutions: number[] 20 resolutions: number[]
21 isNewVideo: boolean 21 isNewVideo: boolean
diff --git a/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts b/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts
index 80dc05bfb..15fc814ae 100644
--- a/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts
+++ b/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts
@@ -12,7 +12,7 @@ export abstract class AbstractJobBuilder {
12 }): Promise<any> 12 }): Promise<any>
13 13
14 abstract createTranscodingJobs (options: { 14 abstract createTranscodingJobs (options: {
15 transcodingType: 'hls' | 'webtorrent' 15 transcodingType: 'hls' | 'webtorrent' | 'web-video' // TODO: remove webtorrent in v7
16 video: MVideoFullLight 16 video: MVideoFullLight
17 resolutions: number[] 17 resolutions: number[]
18 isNewVideo: boolean 18 isNewVideo: boolean
diff --git a/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts b/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts
index 4f802e2a6..2ecd57249 100644
--- a/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts
+++ b/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts
@@ -12,7 +12,7 @@ import { ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS, hasAud
12import { 12import {
13 HLSTranscodingPayload, 13 HLSTranscodingPayload,
14 MergeAudioTranscodingPayload, 14 MergeAudioTranscodingPayload,
15 NewWebTorrentResolutionTranscodingPayload, 15 NewWebVideoResolutionTranscodingPayload,
16 OptimizeTranscodingPayload, 16 OptimizeTranscodingPayload,
17 VideoTranscodingPayload 17 VideoTranscodingPayload
18} from '@shared/models' 18} from '@shared/models'
@@ -33,7 +33,7 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
33 const { video, videoFile, isNewVideo, user, videoFileAlreadyLocked } = options 33 const { video, videoFile, isNewVideo, user, videoFileAlreadyLocked } = options
34 34
35 let mergeOrOptimizePayload: MergeAudioTranscodingPayload | OptimizeTranscodingPayload 35 let mergeOrOptimizePayload: MergeAudioTranscodingPayload | OptimizeTranscodingPayload
36 let nextTranscodingSequentialJobPayloads: (NewWebTorrentResolutionTranscodingPayload | HLSTranscodingPayload)[][] = [] 36 let nextTranscodingSequentialJobPayloads: (NewWebVideoResolutionTranscodingPayload | HLSTranscodingPayload)[][] = []
37 37
38 const mutexReleaser = videoFileAlreadyLocked 38 const mutexReleaser = videoFileAlreadyLocked
39 ? () => {} 39 ? () => {}
@@ -60,7 +60,7 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
60 if (CONFIG.TRANSCODING.HLS.ENABLED === true) { 60 if (CONFIG.TRANSCODING.HLS.ENABLED === true) {
61 nextTranscodingSequentialJobPayloads.push([ 61 nextTranscodingSequentialJobPayloads.push([
62 this.buildHLSJobPayload({ 62 this.buildHLSJobPayload({
63 deleteWebTorrentFiles: CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false, 63 deleteWebVideoFiles: CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false,
64 64
65 // We had some issues with a web video quick transcoded while producing a HLS version of it 65 // We had some issues with a web video quick transcoded while producing a HLS version of it
66 copyCodecs: !quickTranscode, 66 copyCodecs: !quickTranscode,
@@ -116,7 +116,7 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
116 // --------------------------------------------------------------------------- 116 // ---------------------------------------------------------------------------
117 117
118 async createTranscodingJobs (options: { 118 async createTranscodingJobs (options: {
119 transcodingType: 'hls' | 'webtorrent' 119 transcodingType: 'hls' | 'webtorrent' | 'web-video' // TODO: remove webtorrent in v7
120 video: MVideoFullLight 120 video: MVideoFullLight
121 resolutions: number[] 121 resolutions: number[]
122 isNewVideo: boolean 122 isNewVideo: boolean
@@ -138,8 +138,8 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
138 return this.buildHLSJobPayload({ videoUUID: video.uuid, resolution, fps, isNewVideo }) 138 return this.buildHLSJobPayload({ videoUUID: video.uuid, resolution, fps, isNewVideo })
139 } 139 }
140 140
141 if (transcodingType === 'webtorrent') { 141 if (transcodingType === 'webtorrent' || transcodingType === 'web-video') {
142 return this.buildWebTorrentJobPayload({ videoUUID: video.uuid, resolution, fps, isNewVideo }) 142 return this.buildWebVideoJobPayload({ videoUUID: video.uuid, resolution, fps, isNewVideo })
143 } 143 }
144 144
145 throw new Error('Unknown transcoding type') 145 throw new Error('Unknown transcoding type')
@@ -149,7 +149,7 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
149 149
150 const parent = transcodingType === 'hls' 150 const parent = transcodingType === 'hls'
151 ? this.buildHLSJobPayload({ videoUUID: video.uuid, resolution: maxResolution, fps, isNewVideo }) 151 ? this.buildHLSJobPayload({ videoUUID: video.uuid, resolution: maxResolution, fps, isNewVideo })
152 : this.buildWebTorrentJobPayload({ videoUUID: video.uuid, resolution: maxResolution, fps, isNewVideo }) 152 : this.buildWebVideoJobPayload({ videoUUID: video.uuid, resolution: maxResolution, fps, isNewVideo })
153 153
154 // Process the last resolution after the other ones to prevent concurrency issue 154 // Process the last resolution after the other ones to prevent concurrency issue
155 // Because low resolutions use the biggest one as ffmpeg input 155 // Because low resolutions use the biggest one as ffmpeg input
@@ -160,8 +160,8 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
160 160
161 private async createTranscodingJobsWithChildren (options: { 161 private async createTranscodingJobsWithChildren (options: {
162 videoUUID: string 162 videoUUID: string
163 parent: (HLSTranscodingPayload | NewWebTorrentResolutionTranscodingPayload) 163 parent: (HLSTranscodingPayload | NewWebVideoResolutionTranscodingPayload)
164 children: (HLSTranscodingPayload | NewWebTorrentResolutionTranscodingPayload)[] 164 children: (HLSTranscodingPayload | NewWebVideoResolutionTranscodingPayload)[]
165 user: MUserId | null 165 user: MUserId | null
166 }) { 166 }) {
167 const { videoUUID, parent, children, user } = options 167 const { videoUUID, parent, children, user } = options
@@ -203,14 +203,14 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
203 options 203 options
204 ) 204 )
205 205
206 const sequentialPayloads: (NewWebTorrentResolutionTranscodingPayload | HLSTranscodingPayload)[][] = [] 206 const sequentialPayloads: (NewWebVideoResolutionTranscodingPayload | HLSTranscodingPayload)[][] = []
207 207
208 for (const resolution of resolutionsEnabled) { 208 for (const resolution of resolutionsEnabled) {
209 const fps = computeOutputFPS({ inputFPS: inputVideoFPS, resolution }) 209 const fps = computeOutputFPS({ inputFPS: inputVideoFPS, resolution })
210 210
211 if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED) { 211 if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED) {
212 const payloads: (NewWebTorrentResolutionTranscodingPayload | HLSTranscodingPayload)[] = [ 212 const payloads: (NewWebVideoResolutionTranscodingPayload | HLSTranscodingPayload)[] = [
213 this.buildWebTorrentJobPayload({ 213 this.buildWebVideoJobPayload({
214 videoUUID: video.uuid, 214 videoUUID: video.uuid,
215 resolution, 215 resolution,
216 fps, 216 fps,
@@ -253,10 +253,10 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
253 resolution: number 253 resolution: number
254 fps: number 254 fps: number
255 isNewVideo: boolean 255 isNewVideo: boolean
256 deleteWebTorrentFiles?: boolean // default false 256 deleteWebVideoFiles?: boolean // default false
257 copyCodecs?: boolean // default false 257 copyCodecs?: boolean // default false
258 }): HLSTranscodingPayload { 258 }): HLSTranscodingPayload {
259 const { videoUUID, resolution, fps, isNewVideo, deleteWebTorrentFiles = false, copyCodecs = false } = options 259 const { videoUUID, resolution, fps, isNewVideo, deleteWebVideoFiles = false, copyCodecs = false } = options
260 260
261 return { 261 return {
262 type: 'new-resolution-to-hls', 262 type: 'new-resolution-to-hls',
@@ -265,20 +265,20 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
265 fps, 265 fps,
266 copyCodecs, 266 copyCodecs,
267 isNewVideo, 267 isNewVideo,
268 deleteWebTorrentFiles 268 deleteWebVideoFiles
269 } 269 }
270 } 270 }
271 271
272 private buildWebTorrentJobPayload (options: { 272 private buildWebVideoJobPayload (options: {
273 videoUUID: string 273 videoUUID: string
274 resolution: number 274 resolution: number
275 fps: number 275 fps: number
276 isNewVideo: boolean 276 isNewVideo: boolean
277 }): NewWebTorrentResolutionTranscodingPayload { 277 }): NewWebVideoResolutionTranscodingPayload {
278 const { videoUUID, resolution, fps, isNewVideo } = options 278 const { videoUUID, resolution, fps, isNewVideo } = options
279 279
280 return { 280 return {
281 type: 'new-resolution-to-webtorrent', 281 type: 'new-resolution-to-web-video',
282 videoUUID, 282 videoUUID,
283 isNewVideo, 283 isNewVideo,
284 resolution, 284 resolution,
@@ -294,7 +294,7 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
294 const { videoUUID, isNewVideo, hasChildren } = options 294 const { videoUUID, isNewVideo, hasChildren } = options
295 295
296 return { 296 return {
297 type: 'merge-audio-to-webtorrent', 297 type: 'merge-audio-to-web-video',
298 resolution: DEFAULT_AUDIO_RESOLUTION, 298 resolution: DEFAULT_AUDIO_RESOLUTION,
299 fps: VIDEO_TRANSCODING_FPS.AUDIO_MERGE, 299 fps: VIDEO_TRANSCODING_FPS.AUDIO_MERGE,
300 videoUUID, 300 videoUUID,
@@ -312,7 +312,7 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
312 const { videoUUID, quickTranscode, isNewVideo, hasChildren } = options 312 const { videoUUID, quickTranscode, isNewVideo, hasChildren } = options
313 313
314 return { 314 return {
315 type: 'optimize-to-webtorrent', 315 type: 'optimize-to-web-video',
316 videoUUID, 316 videoUUID,
317 isNewVideo, 317 isNewVideo,
318 hasChildren, 318 hasChildren,
diff --git a/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts b/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts
index 4b8bc2f3d..b98172c2d 100644
--- a/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts
+++ b/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts
@@ -89,7 +89,7 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder {
89 // --------------------------------------------------------------------------- 89 // ---------------------------------------------------------------------------
90 90
91 async createTranscodingJobs (options: { 91 async createTranscodingJobs (options: {
92 transcodingType: 'hls' | 'webtorrent' 92 transcodingType: 'hls' | 'webtorrent' | 'web-video' // TODO: remove webtorrent in v7
93 video: MVideoFullLight 93 video: MVideoFullLight
94 resolutions: number[] 94 resolutions: number[]
95 isNewVideo: boolean 95 isNewVideo: boolean
@@ -130,7 +130,7 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder {
130 continue 130 continue
131 } 131 }
132 132
133 if (transcodingType === 'webtorrent') { 133 if (transcodingType === 'webtorrent' || transcodingType === 'web-video') {
134 await new VODWebVideoTranscodingJobHandler().create({ 134 await new VODWebVideoTranscodingJobHandler().create({
135 video, 135 video,
136 resolution, 136 resolution,
diff --git a/server/lib/transcoding/web-transcoding.ts b/server/lib/transcoding/web-transcoding.ts
index a499db422..f92d457a0 100644
--- a/server/lib/transcoding/web-transcoding.ts
+++ b/server/lib/transcoding/web-transcoding.ts
@@ -10,7 +10,7 @@ import { VideoResolution, VideoStorage } from '@shared/models'
10import { CONFIG } from '../../initializers/config' 10import { CONFIG } from '../../initializers/config'
11import { VideoFileModel } from '../../models/video/video-file' 11import { VideoFileModel } from '../../models/video/video-file'
12import { JobQueue } from '../job-queue' 12import { JobQueue } from '../job-queue'
13import { generateWebTorrentVideoFilename } from '../paths' 13import { generateWebVideoFilename } from '../paths'
14import { buildFileMetadata } from '../video-file' 14import { buildFileMetadata } from '../video-file'
15import { VideoPathManager } from '../video-path-manager' 15import { VideoPathManager } from '../video-path-manager'
16import { buildFFmpegVOD } from './shared' 16import { buildFFmpegVOD } from './shared'
@@ -63,10 +63,10 @@ export async function optimizeOriginalVideofile (options: {
63 // Important to do this before getVideoFilename() to take in account the new filename 63 // Important to do this before getVideoFilename() to take in account the new filename
64 inputVideoFile.resolution = resolution 64 inputVideoFile.resolution = resolution
65 inputVideoFile.extname = newExtname 65 inputVideoFile.extname = newExtname
66 inputVideoFile.filename = generateWebTorrentVideoFilename(resolution, newExtname) 66 inputVideoFile.filename = generateWebVideoFilename(resolution, newExtname)
67 inputVideoFile.storage = VideoStorage.FILE_SYSTEM 67 inputVideoFile.storage = VideoStorage.FILE_SYSTEM
68 68
69 const { videoFile } = await onWebTorrentVideoFileTranscoding({ 69 const { videoFile } = await onWebVideoFileTranscoding({
70 video, 70 video,
71 videoFile: inputVideoFile, 71 videoFile: inputVideoFile,
72 videoOutputPath 72 videoOutputPath
@@ -83,8 +83,8 @@ export async function optimizeOriginalVideofile (options: {
83 } 83 }
84} 84}
85 85
86// Transcode the original video file to a lower resolution compatible with WebTorrent 86// Transcode the original video file to a lower resolution compatible with web browsers
87export async function transcodeNewWebTorrentResolution (options: { 87export async function transcodeNewWebVideoResolution (options: {
88 video: MVideoFullLight 88 video: MVideoFullLight
89 resolution: VideoResolution 89 resolution: VideoResolution
90 fps: number 90 fps: number
@@ -105,7 +105,7 @@ export async function transcodeNewWebTorrentResolution (options: {
105 const newVideoFile = new VideoFileModel({ 105 const newVideoFile = new VideoFileModel({
106 resolution, 106 resolution,
107 extname: newExtname, 107 extname: newExtname,
108 filename: generateWebTorrentVideoFilename(resolution, newExtname), 108 filename: generateWebVideoFilename(resolution, newExtname),
109 size: 0, 109 size: 0,
110 videoId: video.id 110 videoId: video.id
111 }) 111 })
@@ -126,7 +126,7 @@ export async function transcodeNewWebTorrentResolution (options: {
126 126
127 await buildFFmpegVOD(job).transcode(transcodeOptions) 127 await buildFFmpegVOD(job).transcode(transcodeOptions)
128 128
129 return onWebTorrentVideoFileTranscoding({ video, videoFile: newVideoFile, videoOutputPath }) 129 return onWebVideoFileTranscoding({ video, videoFile: newVideoFile, videoOutputPath })
130 }) 130 })
131 131
132 return result 132 return result
@@ -189,14 +189,14 @@ export async function mergeAudioVideofile (options: {
189 // Important to do this before getVideoFilename() to take in account the new file extension 189 // Important to do this before getVideoFilename() to take in account the new file extension
190 inputVideoFile.extname = newExtname 190 inputVideoFile.extname = newExtname
191 inputVideoFile.resolution = resolution 191 inputVideoFile.resolution = resolution
192 inputVideoFile.filename = generateWebTorrentVideoFilename(inputVideoFile.resolution, newExtname) 192 inputVideoFile.filename = generateWebVideoFilename(inputVideoFile.resolution, newExtname)
193 193
194 // ffmpeg generated a new video file, so update the video duration 194 // ffmpeg generated a new video file, so update the video duration
195 // See https://trac.ffmpeg.org/ticket/5456 195 // See https://trac.ffmpeg.org/ticket/5456
196 video.duration = await getVideoStreamDuration(videoOutputPath) 196 video.duration = await getVideoStreamDuration(videoOutputPath)
197 await video.save() 197 await video.save()
198 198
199 return onWebTorrentVideoFileTranscoding({ 199 return onWebVideoFileTranscoding({
200 video, 200 video,
201 videoFile: inputVideoFile, 201 videoFile: inputVideoFile,
202 videoOutputPath, 202 videoOutputPath,
@@ -210,7 +210,7 @@ export async function mergeAudioVideofile (options: {
210 } 210 }
211} 211}
212 212
213export async function onWebTorrentVideoFileTranscoding (options: { 213export async function onWebVideoFileTranscoding (options: {
214 video: MVideoFullLight 214 video: MVideoFullLight
215 videoFile: MVideoFile 215 videoFile: MVideoFile
216 videoOutputPath: string 216 videoOutputPath: string
@@ -239,8 +239,8 @@ export async function onWebTorrentVideoFileTranscoding (options: {
239 239
240 await createTorrentAndSetInfoHash(video, videoFile) 240 await createTorrentAndSetInfoHash(video, videoFile)
241 241
242 const oldFile = await VideoFileModel.loadWebTorrentFile({ videoId: video.id, fps: videoFile.fps, resolution: videoFile.resolution }) 242 const oldFile = await VideoFileModel.loadWebVideoFile({ videoId: video.id, fps: videoFile.fps, resolution: videoFile.resolution })
243 if (oldFile) await video.removeWebTorrentFile(oldFile) 243 if (oldFile) await video.removeWebVideoFile(oldFile)
244 244
245 await VideoFileModel.customUpsert(videoFile, 'video', undefined) 245 await VideoFileModel.customUpsert(videoFile, 'video', undefined)
246 video.VideoFiles = await video.$get('VideoFiles') 246 video.VideoFiles = await video.$get('VideoFiles')