diff options
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/videos/upload.ts | 17 |
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' | |||
19 | import { openapiOperationDoc } from '@server/middlewares/doc' | 19 | import { openapiOperationDoc } from '@server/middlewares/doc' |
20 | import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' | 20 | import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' |
21 | import { getLowercaseExtension, uuidToShort } from '@shared/core-utils' | 21 | import { getLowercaseExtension, uuidToShort } from '@shared/core-utils' |
22 | import { isAudioFile } from '@shared/extra-utils' | ||
22 | import { VideoCreate, VideoState } from '../../../../shared' | 23 | import { VideoCreate, VideoState } from '../../../../shared' |
23 | import { HttpStatusCode } from '../../../../shared/models' | 24 | import { HttpStatusCode, VideoResolution } from '../../../../shared/models' |
24 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 25 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
25 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 26 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
26 | import { createReqFiles } from '../../../helpers/express-utils' | 27 | import { createReqFiles } from '../../../helpers/express-utils' |
27 | import { getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' | 28 | import { ffprobePromise, getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' |
28 | import { logger, loggerTagsFactory } from '../../../helpers/logger' | 29 | import { logger, loggerTagsFactory } from '../../../helpers/logger' |
29 | import { CONFIG } from '../../../initializers/config' | 30 | import { CONFIG } from '../../../initializers/config' |
30 | import { DEFAULT_AUDIO_RESOLUTION, MIMETYPES } from '../../../initializers/constants' | 31 | import { MIMETYPES } from '../../../initializers/constants' |
31 | import { sequelizeTypescript } from '../../../initializers/database' | 32 | import { sequelizeTypescript } from '../../../initializers/database' |
32 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' | 33 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' |
33 | import { Notifier } from '../../../lib/notifier' | 34 | import { 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) |