aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/videos/upload.ts17
1 files changed, 10 insertions, 7 deletions
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts
index 9f620c04d..ecc4dfa37 100644
--- a/server/controllers/api/videos/upload.ts
+++ b/server/controllers/api/videos/upload.ts
@@ -19,15 +19,16 @@ import { buildNextVideoState } from '@server/lib/video-state'
19import { openapiOperationDoc } from '@server/middlewares/doc' 19import { openapiOperationDoc } from '@server/middlewares/doc'
20import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' 20import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
21import { getLowercaseExtension, uuidToShort } from '@shared/core-utils' 21import { getLowercaseExtension, uuidToShort } from '@shared/core-utils'
22import { isAudioFile } from '@shared/extra-utils'
22import { VideoCreate, VideoState } from '../../../../shared' 23import { VideoCreate, VideoState } from '../../../../shared'
23import { HttpStatusCode } from '../../../../shared/models' 24import { HttpStatusCode, VideoResolution } from '../../../../shared/models'
24import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 25import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
25import { retryTransactionWrapper } from '../../../helpers/database-utils' 26import { retryTransactionWrapper } from '../../../helpers/database-utils'
26import { createReqFiles } from '../../../helpers/express-utils' 27import { createReqFiles } from '../../../helpers/express-utils'
27import { getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' 28import { ffprobePromise, getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils'
28import { logger, loggerTagsFactory } from '../../../helpers/logger' 29import { logger, loggerTagsFactory } from '../../../helpers/logger'
29import { CONFIG } from '../../../initializers/config' 30import { CONFIG } from '../../../initializers/config'
30import { DEFAULT_AUDIO_RESOLUTION, MIMETYPES } from '../../../initializers/constants' 31import { MIMETYPES } from '../../../initializers/constants'
31import { sequelizeTypescript } from '../../../initializers/database' 32import { sequelizeTypescript } from '../../../initializers/database'
32import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' 33import { federateVideoIfNeeded } from '../../../lib/activitypub/videos'
33import { Notifier } from '../../../lib/notifier' 34import { Notifier } from '../../../lib/notifier'
@@ -252,11 +253,13 @@ async function buildNewFile (videoPhysicalFile: express.VideoUploadFile) {
252 metadata: await getMetadataFromFile(videoPhysicalFile.path) 253 metadata: await getMetadataFromFile(videoPhysicalFile.path)
253 }) 254 })
254 255
255 if (videoFile.isAudio()) { 256 const probe = await ffprobePromise(videoPhysicalFile.path)
256 videoFile.resolution = DEFAULT_AUDIO_RESOLUTION 257
258 if (await isAudioFile(videoPhysicalFile.path, probe)) {
259 videoFile.resolution = VideoResolution.H_NOVIDEO
257 } else { 260 } else {
258 videoFile.fps = await getVideoFileFPS(videoPhysicalFile.path) 261 videoFile.fps = await getVideoFileFPS(videoPhysicalFile.path, probe)
259 videoFile.resolution = (await getVideoFileResolution(videoPhysicalFile.path)).resolution 262 videoFile.resolution = (await getVideoFileResolution(videoPhysicalFile.path, probe)).resolution
260 } 263 }
261 264
262 videoFile.filename = generateWebTorrentVideoFilename(videoFile.resolution, videoFile.extname) 265 videoFile.filename = generateWebTorrentVideoFilename(videoFile.resolution, videoFile.extname)