1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Implement video transcoding on server side

This commit is contained in:
Chocobozzz 2017-10-02 12:20:26 +02:00
parent f0adb2701c
commit 40298b0254
19 changed files with 344 additions and 128 deletions

View file

@ -0,0 +1,33 @@
import { database as db } from '../../../initializers/database'
import { updateVideoToFriends } from '../../friends'
import { logger } from '../../../helpers'
import { VideoInstance } from '../../../models'
import { VideoResolution } from '../../../../shared'
function process (data: { videoUUID: string, resolution: VideoResolution }) {
return db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(data.videoUUID).then(video => {
return video.transcodeOriginalVideofile(data.resolution).then(() => video)
})
}
function onError (err: Error, jobId: number) {
logger.error('Error when transcoding video file in job %d.', jobId, err)
return Promise.resolve()
}
function onSuccess (jobId: number, video: VideoInstance) {
logger.info('Job %d is a success.', jobId)
const remoteVideo = video.toUpdateRemoteJSON()
// Now we'll add the video's meta data to our friends
return updateVideoToFriends(remoteVideo, null)
}
// ---------------------------------------------------------------------------
export {
process,
onError,
onSuccess
}