aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos/index.ts')
-rw-r--r--server/controllers/api/videos/index.ts28
1 files changed, 5 insertions, 23 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 9b19c394d..04d775cbf 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { extname } from 'path' 2import { extname } from 'path'
3import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared' 3import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared'
4import { getVideoFileFPS, getVideoFileResolution, getMetadataFromFile } from '../../../helpers/ffmpeg-utils' 4import { getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
5import { logger } from '../../../helpers/logger' 5import { logger } from '../../../helpers/logger'
6import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 6import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
7import { getFormattedObjects, getServerActor } from '../../../helpers/utils' 7import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
@@ -32,13 +32,13 @@ import {
32 paginationValidator, 32 paginationValidator,
33 setDefaultPagination, 33 setDefaultPagination,
34 setDefaultSort, 34 setDefaultSort,
35 videoFileMetadataGetValidator,
35 videosAddValidator, 36 videosAddValidator,
36 videosCustomGetValidator, 37 videosCustomGetValidator,
37 videosGetValidator, 38 videosGetValidator,
38 videosRemoveValidator, 39 videosRemoveValidator,
39 videosSortValidator, 40 videosSortValidator,
40 videosUpdateValidator, 41 videosUpdateValidator
41 videoFileMetadataGetValidator
42} from '../../../middlewares' 42} from '../../../middlewares'
43import { TagModel } from '../../../models/video/tag' 43import { TagModel } from '../../../models/video/tag'
44import { VideoModel } from '../../../models/video/video' 44import { VideoModel } from '../../../models/video/video'
@@ -62,12 +62,12 @@ import { CONFIG } from '../../../initializers/config'
62import { sequelizeTypescript } from '../../../initializers/database' 62import { sequelizeTypescript } from '../../../initializers/database'
63import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail' 63import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail'
64import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' 64import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
65import { VideoTranscodingPayload } from '../../../lib/job-queue/handlers/video-transcoding'
66import { Hooks } from '../../../lib/plugins/hooks' 65import { Hooks } from '../../../lib/plugins/hooks'
67import { MVideoDetails, MVideoFullLight } from '@server/typings/models' 66import { MVideoDetails, MVideoFullLight } from '@server/typings/models'
68import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' 67import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
69import { getVideoFilePath } from '@server/lib/video-paths' 68import { getVideoFilePath } from '@server/lib/video-paths'
70import toInt from 'validator/lib/toInt' 69import toInt from 'validator/lib/toInt'
70import { addOptimizeOrMergeAudioJob } from '@server/lib/videos'
71 71
72const auditLogger = auditLoggerFactory('videos') 72const auditLogger = auditLoggerFactory('videos')
73const videosRouter = express.Router() 73const videosRouter = express.Router()
@@ -296,25 +296,7 @@ async function addVideo (req: express.Request, res: express.Response) {
296 Notifier.Instance.notifyOnNewVideoIfNeeded(videoCreated) 296 Notifier.Instance.notifyOnNewVideoIfNeeded(videoCreated)
297 297
298 if (video.state === VideoState.TO_TRANSCODE) { 298 if (video.state === VideoState.TO_TRANSCODE) {
299 // Put uuid because we don't have id auto incremented for now 299 await addOptimizeOrMergeAudioJob(videoCreated, videoFile)
300 let dataInput: VideoTranscodingPayload
301
302 if (videoFile.isAudio()) {
303 dataInput = {
304 type: 'merge-audio' as 'merge-audio',
305 resolution: DEFAULT_AUDIO_RESOLUTION,
306 videoUUID: videoCreated.uuid,
307 isNewVideo: true
308 }
309 } else {
310 dataInput = {
311 type: 'optimize' as 'optimize',
312 videoUUID: videoCreated.uuid,
313 isNewVideo: true
314 }
315 }
316
317 await JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput })
318 } 300 }
319 301
320 Hooks.runAction('action:api.video.uploaded', { video: videoCreated }) 302 Hooks.runAction('action:api.video.uploaded', { video: videoCreated })