From d57d1d83c6a4d98a735b21f4e8e749a5c1e1a479 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 3 Apr 2020 15:41:39 +0200 Subject: Support audio files import --- server/lib/videos.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'server/lib/videos.ts') diff --git a/server/lib/videos.ts b/server/lib/videos.ts index 22e9afbf9..96bdd42e9 100644 --- a/server/lib/videos.ts +++ b/server/lib/videos.ts @@ -1,4 +1,7 @@ -import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/typings/models' +import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile } from '@server/typings/models' +import { VideoTranscodingPayload } from '@server/lib/job-queue/handlers/video-transcoding' +import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' +import { JobQueue } from '@server/lib/job-queue' function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { return isStreamingPlaylist(videoOrPlaylist) @@ -6,6 +9,28 @@ function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { : videoOrPlaylist } +function addOptimizeOrMergeAudioJob (video: MVideo, videoFile: MVideoFile) { + let dataInput: VideoTranscodingPayload + + if (videoFile.isAudio()) { + dataInput = { + type: 'merge-audio' as 'merge-audio', + resolution: DEFAULT_AUDIO_RESOLUTION, + videoUUID: video.uuid, + isNewVideo: true + } + } else { + dataInput = { + type: 'optimize' as 'optimize', + videoUUID: video.uuid, + isNewVideo: true + } + } + + return JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput }) +} + export { + addOptimizeOrMergeAudioJob, extractVideo } -- cgit v1.2.3