aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/transcoding/web-transcoding.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/transcoding/web-transcoding.ts')
-rw-r--r--server/lib/transcoding/web-transcoding.ts24
1 files changed, 12 insertions, 12 deletions
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')