diff options
Diffstat (limited to 'server/controllers/api/videos/upload.ts')
-rw-r--r-- | server/controllers/api/videos/upload.ts | 21 |
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 | |||
24 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 24 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
25 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 25 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
26 | import { createReqFiles } from '../../../helpers/express-utils' | 26 | import { createReqFiles } from '../../../helpers/express-utils' |
27 | import { ffprobePromise, getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' | 27 | import { buildFileMetadata, ffprobePromise, getVideoStreamDimensionsInfo, getVideoStreamFPS } from '../../../helpers/ffmpeg' |
28 | import { logger, loggerTagsFactory } from '../../../helpers/logger' | 28 | import { logger, loggerTagsFactory } from '../../../helpers/logger' |
29 | import { CONFIG } from '../../../initializers/config' | ||
30 | import { MIMETYPES } from '../../../initializers/constants' | 29 | import { MIMETYPES } from '../../../initializers/constants' |
31 | import { sequelizeTypescript } from '../../../initializers/database' | 30 | import { sequelizeTypescript } from '../../../initializers/database' |
32 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' | 31 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' |
@@ -52,21 +51,13 @@ const uploadRouter = express.Router() | |||
52 | 51 | ||
53 | const reqVideoFileAdd = createReqFiles( | 52 | const 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 | ||
63 | const reqVideoFileAddResumable = createReqFiles( | 57 | const 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 | ||
72 | uploadRouter.post('/upload', | 63 | uploadRouter.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) |