aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/video-transcoding.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/video-transcoding.ts')
-rw-r--r--server/lib/video-transcoding.ts15
1 files changed, 10 insertions, 5 deletions
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts
index bf3ff78c2..04cadf74b 100644
--- a/server/lib/video-transcoding.ts
+++ b/server/lib/video-transcoding.ts
@@ -1,5 +1,5 @@
1import { CONFIG } from '../initializers' 1import { CONFIG } from '../initializers'
2import { join, extname } from 'path' 2import { join, extname, basename } from 'path'
3import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils' 3import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils'
4import { copy, remove, rename, stat } from 'fs-extra' 4import { copy, remove, rename, stat } from 'fs-extra'
5import { logger } from '../helpers/logger' 5import { logger } from '../helpers/logger'
@@ -7,11 +7,16 @@ import { VideoResolution } from '../../shared/models/videos'
7import { VideoFileModel } from '../models/video/video-file' 7import { VideoFileModel } from '../models/video/video-file'
8import { VideoModel } from '../models/video/video' 8import { VideoModel } from '../models/video/video'
9 9
10async function optimizeOriginalVideofile (video: VideoModel) { 10async function optimizeVideofile (video: VideoModel, videoInputPath?: string) {
11 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR 11 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR
12 const newExtname = '.mp4' 12 const newExtname = '.mp4'
13 const inputVideoFile = video.getOriginalFile() 13 let inputVideoFile = null
14 const videoInputPath = join(videosDirectory, video.getVideoFilename(inputVideoFile)) 14 if (videoInputPath == null) {
15 inputVideoFile = video.getOriginalFile()
16 videoInputPath = join(videosDirectory, video.getVideoFilename(inputVideoFile))
17 } else {
18 inputVideoFile = basename(videoInputPath)
19 }
15 const videoTranscodedPath = join(videosDirectory, video.id + '-transcoded' + newExtname) 20 const videoTranscodedPath = join(videosDirectory, video.id + '-transcoded' + newExtname)
16 21
17 const transcodeOptions = { 22 const transcodeOptions = {
@@ -124,7 +129,7 @@ async function importVideoFile (video: VideoModel, inputFilePath: string) {
124} 129}
125 130
126export { 131export {
127 optimizeOriginalVideofile, 132 optimizeVideofile,
128 transcodeOriginalVideofile, 133 transcodeOriginalVideofile,
129 importVideoFile 134 importVideoFile
130} 135}