aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/jobs/handlers/video-file-transcoder.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-02 12:20:26 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-03 15:31:26 +0200
commit40298b02546e8225dd21bf6048fe7f224aefc32a (patch)
tree0a0b981dbeb2af47810adff6553a0df995a03734 /server/lib/jobs/handlers/video-file-transcoder.ts
parentf0adb2701c1cf404ff63095f71e542bfe6d025ae (diff)
downloadPeerTube-40298b02546e8225dd21bf6048fe7f224aefc32a.tar.gz
PeerTube-40298b02546e8225dd21bf6048fe7f224aefc32a.tar.zst
PeerTube-40298b02546e8225dd21bf6048fe7f224aefc32a.zip
Implement video transcoding on server side
Diffstat (limited to 'server/lib/jobs/handlers/video-file-transcoder.ts')
-rw-r--r--server/lib/jobs/handlers/video-file-transcoder.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/server/lib/jobs/handlers/video-file-transcoder.ts b/server/lib/jobs/handlers/video-file-transcoder.ts
new file mode 100644
index 000000000..0e45b4dca
--- /dev/null
+++ b/server/lib/jobs/handlers/video-file-transcoder.ts
@@ -0,0 +1,33 @@
1import { database as db } from '../../../initializers/database'
2import { updateVideoToFriends } from '../../friends'
3import { logger } from '../../../helpers'
4import { VideoInstance } from '../../../models'
5import { VideoResolution } from '../../../../shared'
6
7function process (data: { videoUUID: string, resolution: VideoResolution }) {
8 return db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(data.videoUUID).then(video => {
9 return video.transcodeOriginalVideofile(data.resolution).then(() => video)
10 })
11}
12
13function onError (err: Error, jobId: number) {
14 logger.error('Error when transcoding video file in job %d.', jobId, err)
15 return Promise.resolve()
16}
17
18function onSuccess (jobId: number, video: VideoInstance) {
19 logger.info('Job %d is a success.', jobId)
20
21 const remoteVideo = video.toUpdateRemoteJSON()
22
23 // Now we'll add the video's meta data to our friends
24 return updateVideoToFriends(remoteVideo, null)
25}
26
27// ---------------------------------------------------------------------------
28
29export {
30 process,
31 onError,
32 onSuccess
33}