aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/jobs/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/jobs/handlers')
-rw-r--r--server/lib/jobs/handlers/index.js7
-rw-r--r--server/lib/jobs/handlers/video-transcoder.js34
2 files changed, 41 insertions, 0 deletions
diff --git a/server/lib/jobs/handlers/index.js b/server/lib/jobs/handlers/index.js
new file mode 100644
index 000000000..59c1ccce5
--- /dev/null
+++ b/server/lib/jobs/handlers/index.js
@@ -0,0 +1,7 @@
1'use strict'
2
3const videoTranscoder = require('./video-transcoder')
4
5module.exports = {
6 videoTranscoder
7}
diff --git a/server/lib/jobs/handlers/video-transcoder.js b/server/lib/jobs/handlers/video-transcoder.js
new file mode 100644
index 000000000..8524df3aa
--- /dev/null
+++ b/server/lib/jobs/handlers/video-transcoder.js
@@ -0,0 +1,34 @@
1'use strict'
2
3const db = require('../../../initializers/database')
4const logger = require('../../../helpers/logger')
5
6const VideoTranscoderHandler = {
7 process,
8 onError,
9 onSuccess
10}
11
12// ---------------------------------------------------------------------------
13
14function process (data, callback) {
15 db.Video.load(data.id, function (err, video) {
16 if (err) return callback(err)
17
18 video.transcodeVideofile(callback)
19 })
20}
21
22function onError (err, jobId, callback) {
23 logger.error('Error when transcoding video file in job %d.', jobId, { error: err })
24 return callback()
25}
26
27function onSuccess (data, jobId, callback) {
28 logger.info('Job %d is a success.', jobId)
29 return callback()
30}
31
32// ---------------------------------------------------------------------------
33
34module.exports = VideoTranscoderHandler