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