]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/jobs/handlers/video-transcoder.ts
Modify video file size to bigint
[github/Chocobozzz/PeerTube.git] / server / lib / jobs / handlers / video-transcoder.ts
CommitLineData
e02643f3 1import { database as db } from '../../../initializers/database'
65fcc311
C
2import { logger } from '../../../helpers'
3import { addVideoToFriends } from '../../../lib'
69818c93 4import { VideoInstance } from '../../../models'
227d02fe 5
0a6658fd
C
6function process (data: { videoUUID: string }) {
7 return db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(data.videoUUID).then(video => {
93e1258c
C
8 // TODO: handle multiple resolutions
9 const videoFile = video.VideoFiles[0]
10 return video.transcodeVideofile(videoFile).then(() => video)
227d02fe
C
11 })
12}
13
6fcd19ba 14function onError (err: Error, jobId: number) {
ad0997ad 15 logger.error('Error when transcoding video file in job %d.', jobId, err)
6fcd19ba 16 return Promise.resolve()
227d02fe
C
17}
18
6fcd19ba 19function onSuccess (jobId: number, video: VideoInstance) {
227d02fe 20 logger.info('Job %d is a success.', jobId)
62326afb 21
6fcd19ba 22 video.toAddRemoteJSON().then(remoteVideo => {
62326afb 23 // Now we'll add the video's meta data to our friends
6fcd19ba 24 return addVideoToFriends(remoteVideo, null)
62326afb 25 })
227d02fe
C
26}
27
28// ---------------------------------------------------------------------------
29
65fcc311
C
30export {
31 process,
32 onError,
33 onSuccess
34}