const async = require('async')
const config = require('config')
+const ffmpeg = require('fluent-ffmpeg')
const pathUtils = require('path')
const webtorrent = require('../lib/webtorrent')
const uploadDir = pathUtils.join(__dirname, '..', '..', config.get('storage.uploads'))
const videos = {
+ getVideoDuration: getVideoDuration,
getVideoState: getVideoState,
seed: seed,
seedAllExisting: seedAllExisting
}
-function getVideoState (video, callback) {
+function getVideoDuration (video_path, callback) {
+ ffmpeg.ffprobe(video_path, function (err, metadata) {
+ if (err) return callback(err)
+
+ return callback(null, Math.floor(metadata.format.duration))
+ })
+}
+
+function getVideoState (video) {
const exist = (video !== null)
let owned = false
if (exist === true) {
owned = (video.namePath !== null)
}
- return callback({ exist: exist, owned: owned })
+ return { exist: exist, owned: owned }
}
function seed (path, callback) {