aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/upload.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos/upload.ts')
-rw-r--r--server/controllers/api/videos/upload.ts21
1 files changed, 6 insertions, 15 deletions
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts
index fd90d9915..dd69cf238 100644
--- a/server/controllers/api/videos/upload.ts
+++ b/server/controllers/api/videos/upload.ts
@@ -24,9 +24,8 @@ import { HttpStatusCode, VideoCreate, VideoResolution, VideoState } from '@share
24import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 24import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
25import { retryTransactionWrapper } from '../../../helpers/database-utils' 25import { retryTransactionWrapper } from '../../../helpers/database-utils'
26import { createReqFiles } from '../../../helpers/express-utils' 26import { createReqFiles } from '../../../helpers/express-utils'
27import { ffprobePromise, getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' 27import { buildFileMetadata, ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '../../../helpers/ffmpeg'
28import { logger, loggerTagsFactory } from '../../../helpers/logger' 28import { logger, loggerTagsFactory } from '../../../helpers/logger'
29import { CONFIG } from '../../../initializers/config'
30import { MIMETYPES } from '../../../initializers/constants' 29import { MIMETYPES } from '../../../initializers/constants'
31import { sequelizeTypescript } from '../../../initializers/database' 30import { sequelizeTypescript } from '../../../initializers/database'
32import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' 31import { federateVideoIfNeeded } from '../../../lib/activitypub/videos'
@@ -52,21 +51,13 @@ const uploadRouter = express.Router()
52 51
53const reqVideoFileAdd = createReqFiles( 52const reqVideoFileAdd = createReqFiles(
54 [ 'videofile', 'thumbnailfile', 'previewfile' ], 53 [ 'videofile', 'thumbnailfile', 'previewfile' ],
55 Object.assign({}, MIMETYPES.VIDEO.MIMETYPE_EXT, MIMETYPES.IMAGE.MIMETYPE_EXT), 54 { ...MIMETYPES.VIDEO.MIMETYPE_EXT, ...MIMETYPES.IMAGE.MIMETYPE_EXT }
56 {
57 videofile: CONFIG.STORAGE.TMP_DIR,
58 thumbnailfile: CONFIG.STORAGE.TMP_DIR,
59 previewfile: CONFIG.STORAGE.TMP_DIR
60 }
61) 55)
62 56
63const reqVideoFileAddResumable = createReqFiles( 57const reqVideoFileAddResumable = createReqFiles(
64 [ 'thumbnailfile', 'previewfile' ], 58 [ 'thumbnailfile', 'previewfile' ],
65 MIMETYPES.IMAGE.MIMETYPE_EXT, 59 MIMETYPES.IMAGE.MIMETYPE_EXT,
66 { 60 getResumableUploadPath()
67 thumbnailfile: getResumableUploadPath(),
68 previewfile: getResumableUploadPath()
69 }
70) 61)
71 62
72uploadRouter.post('/upload', 63uploadRouter.post('/upload',
@@ -246,7 +237,7 @@ async function buildNewFile (videoPhysicalFile: express.VideoUploadFile) {
246 extname: getLowercaseExtension(videoPhysicalFile.filename), 237 extname: getLowercaseExtension(videoPhysicalFile.filename),
247 size: videoPhysicalFile.size, 238 size: videoPhysicalFile.size,
248 videoStreamingPlaylistId: null, 239 videoStreamingPlaylistId: null,
249 metadata: await getMetadataFromFile(videoPhysicalFile.path) 240 metadata: await buildFileMetadata(videoPhysicalFile.path)
250 }) 241 })
251 242
252 const probe = await ffprobePromise(videoPhysicalFile.path) 243 const probe = await ffprobePromise(videoPhysicalFile.path)
@@ -254,8 +245,8 @@ async function buildNewFile (videoPhysicalFile: express.VideoUploadFile) {
254 if (await isAudioFile(videoPhysicalFile.path, probe)) { 245 if (await isAudioFile(videoPhysicalFile.path, probe)) {
255 videoFile.resolution = VideoResolution.H_NOVIDEO 246 videoFile.resolution = VideoResolution.H_NOVIDEO
256 } else { 247 } else {
257 videoFile.fps = await getVideoFileFPS(videoPhysicalFile.path, probe) 248 videoFile.fps = await getVideoStreamFPS(videoPhysicalFile.path, probe)
258 videoFile.resolution = (await getVideoFileResolution(videoPhysicalFile.path, probe)).resolution 249 videoFile.resolution = (await getVideoStreamDimensionsInfo(videoPhysicalFile.path, probe)).resolution
259 } 250 }
260 251
261 videoFile.filename = generateWebTorrentVideoFilename(videoFile.resolution, videoFile.extname) 252 videoFile.filename = generateWebTorrentVideoFilename(videoFile.resolution, videoFile.extname)