aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/config.ts1
-rw-r--r--server/controllers/api/videos/index.ts43
-rw-r--r--server/controllers/static.ts2
3 files changed, 34 insertions, 12 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index 40012c03b..d9ce6a153 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -255,6 +255,7 @@ function customConfig (): CustomConfig {
255 transcoding: { 255 transcoding: {
256 enabled: CONFIG.TRANSCODING.ENABLED, 256 enabled: CONFIG.TRANSCODING.ENABLED,
257 allowAdditionalExtensions: CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS, 257 allowAdditionalExtensions: CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS,
258 allowAudioFiles: CONFIG.TRANSCODING.ALLOW_AUDIO_FILES,
258 threads: CONFIG.TRANSCODING.THREADS, 259 threads: CONFIG.TRANSCODING.THREADS,
259 resolutions: { 260 resolutions: {
260 '240p': CONFIG.TRANSCODING.RESOLUTIONS[ '240p' ], 261 '240p': CONFIG.TRANSCODING.RESOLUTIONS[ '240p' ],
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 1a18a8ae8..40a2c972b 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -6,7 +6,14 @@ import { 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'
8import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' 8import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
9import { MIMETYPES, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants' 9import {
10 DEFAULT_AUDIO_RESOLUTION,
11 MIMETYPES,
12 VIDEO_CATEGORIES,
13 VIDEO_LANGUAGES,
14 VIDEO_LICENCES,
15 VIDEO_PRIVACIES
16} from '../../../initializers/constants'
10import { 17import {
11 changeVideoChannelShare, 18 changeVideoChannelShare,
12 federateVideoIfNeeded, 19 federateVideoIfNeeded,
@@ -54,6 +61,7 @@ import { CONFIG } from '../../../initializers/config'
54import { sequelizeTypescript } from '../../../initializers/database' 61import { sequelizeTypescript } from '../../../initializers/database'
55import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail' 62import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail'
56import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' 63import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
64import { VideoTranscodingPayload } from '../../../lib/job-queue/handlers/video-transcoding'
57 65
58const auditLogger = auditLoggerFactory('videos') 66const auditLogger = auditLoggerFactory('videos')
59const videosRouter = express.Router() 67const videosRouter = express.Router()
@@ -191,18 +199,19 @@ async function addVideo (req: express.Request, res: express.Response) {
191 const video = new VideoModel(videoData) 199 const video = new VideoModel(videoData)
192 video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object 200 video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object
193 201
194 // Build the file object
195 const { videoFileResolution } = await getVideoFileResolution(videoPhysicalFile.path)
196 const fps = await getVideoFileFPS(videoPhysicalFile.path)
197
198 const videoFileData = { 202 const videoFileData = {
199 extname: extname(videoPhysicalFile.filename), 203 extname: extname(videoPhysicalFile.filename),
200 resolution: videoFileResolution, 204 size: videoPhysicalFile.size
201 size: videoPhysicalFile.size,
202 fps
203 } 205 }
204 const videoFile = new VideoFileModel(videoFileData) 206 const videoFile = new VideoFileModel(videoFileData)
205 207
208 if (!videoFile.isAudio()) {
209 videoFile.fps = await getVideoFileFPS(videoPhysicalFile.path)
210 videoFile.resolution = (await getVideoFileResolution(videoPhysicalFile.path)).videoFileResolution
211 } else {
212 videoFile.resolution = DEFAULT_AUDIO_RESOLUTION
213 }
214
206 // Move physical file 215 // Move physical file
207 const videoDir = CONFIG.STORAGE.VIDEOS_DIR 216 const videoDir = CONFIG.STORAGE.VIDEOS_DIR
208 const destination = join(videoDir, video.getVideoFilename(videoFile)) 217 const destination = join(videoDir, video.getVideoFilename(videoFile))
@@ -279,9 +288,21 @@ async function addVideo (req: express.Request, res: express.Response) {
279 288
280 if (video.state === VideoState.TO_TRANSCODE) { 289 if (video.state === VideoState.TO_TRANSCODE) {
281 // Put uuid because we don't have id auto incremented for now 290 // Put uuid because we don't have id auto incremented for now
282 const dataInput = { 291 let dataInput: VideoTranscodingPayload
283 videoUUID: videoCreated.uuid, 292
284 isNewVideo: true 293 if (videoFile.isAudio()) {
294 dataInput = {
295 type: 'merge-audio' as 'merge-audio',
296 resolution: DEFAULT_AUDIO_RESOLUTION,
297 videoUUID: videoCreated.uuid,
298 isNewVideo: true
299 }
300 } else {
301 dataInput = {
302 type: 'optimize' as 'optimize',
303 videoUUID: videoCreated.uuid,
304 isNewVideo: true
305 }
285 } 306 }
286 307
287 await JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput }) 308 await JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput })
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 05019fcc2..d57dba6ce 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -181,7 +181,7 @@ async function getVideoCaption (req: express.Request, res: express.Response) {
181 return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE }) 181 return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE })
182} 182}
183 183
184async function generateNodeinfo (req: express.Request, res: express.Response, next: express.NextFunction) { 184async function generateNodeinfo (req: express.Request, res: express.Response) {
185 const { totalVideos } = await VideoModel.getStats() 185 const { totalVideos } = await VideoModel.getStats()
186 const { totalLocalVideoComments } = await VideoCommentModel.getStats() 186 const { totalLocalVideoComments } = await VideoCommentModel.getStats()
187 const { totalUsers } = await UserModel.getStats() 187 const { totalUsers } = await UserModel.getStats()