aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-03 15:41:39 +0200
committerChocobozzz <me@florianbigard.com>2020-04-03 15:41:39 +0200
commitd57d1d83c6a4d98a735b21f4e8e749a5c1e1a479 (patch)
treed625ca7c2c626fcf186bb55c6852c1e5a7b51c9e /server/lib/videos.ts
parent1fe654e0963da8c2801561be10de3222055a2497 (diff)
downloadPeerTube-d57d1d83c6a4d98a735b21f4e8e749a5c1e1a479.tar.gz
PeerTube-d57d1d83c6a4d98a735b21f4e8e749a5c1e1a479.tar.zst
PeerTube-d57d1d83c6a4d98a735b21f4e8e749a5c1e1a479.zip
Support audio files import
Diffstat (limited to 'server/lib/videos.ts')
-rw-r--r--server/lib/videos.ts27
1 files changed, 26 insertions, 1 deletions
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 @@
1import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/typings/models' 1import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile } from '@server/typings/models'
2import { VideoTranscodingPayload } from '@server/lib/job-queue/handlers/video-transcoding'
3import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants'
4import { JobQueue } from '@server/lib/job-queue'
2 5
3function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { 6function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) {
4 return isStreamingPlaylist(videoOrPlaylist) 7 return isStreamingPlaylist(videoOrPlaylist)
@@ -6,6 +9,28 @@ function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) {
6 : videoOrPlaylist 9 : videoOrPlaylist
7} 10}
8 11
12function addOptimizeOrMergeAudioJob (video: MVideo, videoFile: MVideoFile) {
13 let dataInput: VideoTranscodingPayload
14
15 if (videoFile.isAudio()) {
16 dataInput = {
17 type: 'merge-audio' as 'merge-audio',
18 resolution: DEFAULT_AUDIO_RESOLUTION,
19 videoUUID: video.uuid,
20 isNewVideo: true
21 }
22 } else {
23 dataInput = {
24 type: 'optimize' as 'optimize',
25 videoUUID: video.uuid,
26 isNewVideo: true
27 }
28 }
29
30 return JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput })
31}
32
9export { 33export {
34 addOptimizeOrMergeAudioJob,
10 extractVideo 35 extractVideo
11} 36}