diff options
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/config.ts | 1 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 38 | ||||
-rw-r--r-- | server/controllers/static.ts | 2 |
3 files changed, 28 insertions, 13 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..a2a615a79 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -1,12 +1,12 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { extname, join } from 'path' | 2 | import { extname, join } from 'path' |
3 | import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared' | 3 | import { VideoCreate, VideoPrivacy, VideoResolution, VideoState, VideoUpdate } from '../../../../shared' |
4 | import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' | 4 | import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' |
5 | import { logger } from '../../../helpers/logger' | 5 | import { logger } from '../../../helpers/logger' |
6 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 6 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
7 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' | 7 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' |
8 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' | 8 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' |
9 | import { MIMETYPES, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants' | 9 | import { MIMETYPES, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES, DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' |
10 | import { | 10 | import { |
11 | changeVideoChannelShare, | 11 | changeVideoChannelShare, |
12 | federateVideoIfNeeded, | 12 | federateVideoIfNeeded, |
@@ -54,6 +54,7 @@ import { CONFIG } from '../../../initializers/config' | |||
54 | import { sequelizeTypescript } from '../../../initializers/database' | 54 | import { sequelizeTypescript } from '../../../initializers/database' |
55 | import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail' | 55 | import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail' |
56 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' | 56 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' |
57 | import { VideoTranscodingPayload } from '../../../lib/job-queue/handlers/video-transcoding' | ||
57 | 58 | ||
58 | const auditLogger = auditLoggerFactory('videos') | 59 | const auditLogger = auditLoggerFactory('videos') |
59 | const videosRouter = express.Router() | 60 | const videosRouter = express.Router() |
@@ -191,18 +192,19 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
191 | const video = new VideoModel(videoData) | 192 | const video = new VideoModel(videoData) |
192 | video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object | 193 | video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object |
193 | 194 | ||
194 | // Build the file object | ||
195 | const { videoFileResolution } = await getVideoFileResolution(videoPhysicalFile.path) | ||
196 | const fps = await getVideoFileFPS(videoPhysicalFile.path) | ||
197 | |||
198 | const videoFileData = { | 195 | const videoFileData = { |
199 | extname: extname(videoPhysicalFile.filename), | 196 | extname: extname(videoPhysicalFile.filename), |
200 | resolution: videoFileResolution, | 197 | size: videoPhysicalFile.size |
201 | size: videoPhysicalFile.size, | ||
202 | fps | ||
203 | } | 198 | } |
204 | const videoFile = new VideoFileModel(videoFileData) | 199 | const videoFile = new VideoFileModel(videoFileData) |
205 | 200 | ||
201 | if (!videoFile.isAudio()) { | ||
202 | videoFile.fps = await getVideoFileFPS(videoPhysicalFile.path) | ||
203 | videoFile.resolution = (await getVideoFileResolution(videoPhysicalFile.path)).videoFileResolution | ||
204 | } else { | ||
205 | videoFile.resolution = DEFAULT_AUDIO_RESOLUTION | ||
206 | } | ||
207 | |||
206 | // Move physical file | 208 | // Move physical file |
207 | const videoDir = CONFIG.STORAGE.VIDEOS_DIR | 209 | const videoDir = CONFIG.STORAGE.VIDEOS_DIR |
208 | const destination = join(videoDir, video.getVideoFilename(videoFile)) | 210 | const destination = join(videoDir, video.getVideoFilename(videoFile)) |
@@ -279,9 +281,21 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
279 | 281 | ||
280 | if (video.state === VideoState.TO_TRANSCODE) { | 282 | if (video.state === VideoState.TO_TRANSCODE) { |
281 | // Put uuid because we don't have id auto incremented for now | 283 | // Put uuid because we don't have id auto incremented for now |
282 | const dataInput = { | 284 | let dataInput: VideoTranscodingPayload |
283 | videoUUID: videoCreated.uuid, | 285 | |
284 | isNewVideo: true | 286 | if (videoFile.isAudio()) { |
287 | dataInput = { | ||
288 | type: 'merge-audio' as 'merge-audio', | ||
289 | resolution: DEFAULT_AUDIO_RESOLUTION, | ||
290 | videoUUID: videoCreated.uuid, | ||
291 | isNewVideo: true | ||
292 | } | ||
293 | } else { | ||
294 | dataInput = { | ||
295 | type: 'optimize' as 'optimize', | ||
296 | videoUUID: videoCreated.uuid, | ||
297 | isNewVideo: true | ||
298 | } | ||
285 | } | 299 | } |
286 | 300 | ||
287 | await JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput }) | 301 | 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 | ||
184 | async function generateNodeinfo (req: express.Request, res: express.Response, next: express.NextFunction) { | 184 | async 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() |