]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/lib/jobs/handlers/video-file-transcoder.ts
Improve transcoding quality
[github/Chocobozzz/PeerTube.git] / server / lib / jobs / handlers / video-file-transcoder.ts
... / ...
CommitLineData
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}