X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fvideos.js;h=43d6c6b9992d6a46a8796787f53295a654fbdca7;hb=0ae6a09d40fd30c86a2e0bd953830020c56045cd;hp=24178561d9c2dbcf0ea751b0c6893b5873f7809f;hpb=ae852eaf2da4dc88b638c79b8bbb07b91faf7dc7;p=github%2FChocobozzz%2FPeerTube.git 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 @@ const async = require('async') const config = require('config') +const ffmpeg = require('fluent-ffmpeg') const pathUtils = require('path') const webtorrent = require('../lib/webtorrent') @@ -11,11 +12,20 @@ const Videos = require('../models/videos') const uploadDir = pathUtils.join(__dirname, '..', '..', config.get('storage.uploads')) const videos = { + getVideoDuration: getVideoDuration, getVideoState: getVideoState, seed: seed, seedAllExisting: seedAllExisting } +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