PeerTube/server/lib/jobs/handlers/video-transcoder.ts

38 lines
977 B
TypeScript
Raw Normal View History

const db = require('../../../initializers/database')
2017-05-15 22:22:03 +02:00
import { logger } from '../../../helpers'
import { addVideoToFriends } from '../../../lib'
function process (data, callback) {
db.Video.loadAndPopulateAuthorAndPodAndTags(data.id, function (err, video) {
if (err) return callback(err)
video.transcodeVideofile(function (err) {
return callback(err, video)
})
})
}
function onError (err, jobId, video, callback) {
logger.error('Error when transcoding video file in job %d.', jobId, { error: err })
return callback()
}
function onSuccess (data, jobId, video, callback) {
logger.info('Job %d is a success.', jobId)
video.toAddRemoteJSON(function (err, remoteVideo) {
if (err) return callback(err)
// Now we'll add the video's meta data to our friends
2017-05-15 22:22:03 +02:00
addVideoToFriends(remoteVideo, null, callback)
})
}
// ---------------------------------------------------------------------------
2017-05-15 22:22:03 +02:00
export {
process,
onError,
onSuccess
}