import { copy, stat } from 'fs-extra'
import { getLowercaseExtension } from '@server/helpers/core-utils'
import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
-import { generateWebTorrentVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
+import { CONFIG } from '@server/initializers/config'
+import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'
+import { generateWebTorrentVideoFilename } from '@server/lib/paths'
+import { addMoveToObjectStorageJob } from '@server/lib/video'
+import { VideoPathManager } from '@server/lib/video-path-manager'
import { UserModel } from '@server/models/user/user'
import { MVideoFullLight } from '@server/types/models'
-import { VideoFileImportPayload } from '@shared/models'
+import { VideoFileImportPayload, VideoStorage } from '@shared/models'
import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils'
import { logger } from '../../../helpers/logger'
import { VideoModel } from '../../../models/video/video'
import { VideoFileModel } from '../../../models/video/video-file'
-import { onNewWebTorrentFileResolution } from './video-transcoding'
+import { createHlsJobIfEnabled } from './video-transcoding'
async function processVideoFileImport (job: Bull.Job) {
const payload = job.data as VideoFileImportPayload
const user = await UserModel.loadByChannelActorId(video.VideoChannel.actorId)
- const newResolutionPayload = {
- type: 'new-resolution-to-webtorrent' as 'new-resolution-to-webtorrent',
+ await createHlsJobIfEnabled(user, {
videoUUID: video.uuid,
resolution: data.resolution,
isPortraitMode: data.isPortraitMode,
- copyCodecs: false,
- isNewVideo: false
+ copyCodecs: true,
+ isMaxQuality: false
+ })
+
+ if (CONFIG.OBJECT_STORAGE.ENABLED) {
+ await addMoveToObjectStorageJob(video)
+ } else {
+ await federateVideoIfNeeded(video, false)
}
- await onNewWebTorrentFileResolution(video, user, newResolutionPayload)
return video
}
resolution,
extname: fileExt,
filename: generateWebTorrentVideoFilename(resolution, fileExt),
+ storage: VideoStorage.FILE_SYSTEM,
size,
fps,
videoId: video.id
})
- const outputPath = getVideoFilePath(video, newVideoFile)
+ const outputPath = VideoPathManager.Instance.getFSVideoFileOutputPath(video, newVideoFile)
await copy(inputFilePath, outputPath)
video.VideoFiles.push(newVideoFile)