aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-06 14:44:09 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-06 14:44:09 +0200
commit0ae6a09d40fd30c86a2e0bd953830020c56045cd (patch)
tree286fbbc6036cecead1219cd22cdd51d3e2d042a5 /server/lib
parentae852eaf2da4dc88b638c79b8bbb07b91faf7dc7 (diff)
downloadPeerTube-0ae6a09d40fd30c86a2e0bd953830020c56045cd.tar.gz
PeerTube-0ae6a09d40fd30c86a2e0bd953830020c56045cd.tar.zst
PeerTube-0ae6a09d40fd30c86a2e0bd953830020c56045cd.zip
Move video duration logic in lib/
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/videos.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/server/lib/videos.js b/server/lib/videos.js
index 24178561d..43d6c6b99 100644
--- a/server/lib/videos.js
+++ b/server/lib/videos.js
@@ -2,6 +2,7 @@
2 2
3const async = require('async') 3const async = require('async')
4const config = require('config') 4const config = require('config')
5const ffmpeg = require('fluent-ffmpeg')
5const pathUtils = require('path') 6const pathUtils = require('path')
6const webtorrent = require('../lib/webtorrent') 7const webtorrent = require('../lib/webtorrent')
7 8
@@ -11,11 +12,20 @@ const Videos = require('../models/videos')
11const uploadDir = pathUtils.join(__dirname, '..', '..', config.get('storage.uploads')) 12const uploadDir = pathUtils.join(__dirname, '..', '..', config.get('storage.uploads'))
12 13
13const videos = { 14const videos = {
15 getVideoDuration: getVideoDuration,
14 getVideoState: getVideoState, 16 getVideoState: getVideoState,
15 seed: seed, 17 seed: seed,
16 seedAllExisting: seedAllExisting 18 seedAllExisting: seedAllExisting
17} 19}
18 20
21function getVideoDuration (video_path, callback) {
22 ffmpeg.ffprobe(video_path, function (err, metadata) {
23 if (err) return callback(err)
24
25 return callback(null, Math.floor(metadata.format.duration))
26 })
27}
28
19function getVideoState (video) { 29function getVideoState (video) {
20 const exist = (video !== null) 30 const exist = (video !== null)
21 let owned = false 31 let owned = false