Files: ce8c9a23510ffcaae086aac41d0d04be17ab0af0 / lib / exec-ffmpeg.js
910 bytesRaw
1 | var extend = require('xtend') |
2 | var Path = require('path') |
3 | var ffmpeg = 'ffmpeg' |
4 | var env = extend(process.env) |
5 | |
6 | if (process.platform === 'darwin') { |
7 | ffmpeg = Path.join(__dirname, '..', 'bin', 'ffmpeg-darwin') |
8 | } |
9 | |
10 | if (process.platform === 'linux' && process.arch === 'x64') { |
11 | ffmpeg = Path.join(__dirname, '..', 'bin', 'ffmpeg-linux-x64') |
12 | } |
13 | |
14 | console.log('using ', ffmpeg) |
15 | |
16 | var childProcess = require('child_process') |
17 | |
18 | module.exports = function (args, opts, cb) { |
19 | if (typeof opts === 'function') { |
20 | cb = opts |
21 | opts = null |
22 | } |
23 | childProcess.execFile(ffmpeg, args, extend({ |
24 | env, maxBuffer: 1024 * 1024 * 16, encoding: 'buffer', cwd: process.cwd() |
25 | }, opts), cb) |
26 | } |
27 | |
28 | module.exports.spawn = function (args, opts, cb) { |
29 | if (typeof opts === 'function') { |
30 | cb = opts |
31 | opts = null |
32 | } |
33 | return childProcess.spawn(ffmpeg, args, extend({ |
34 | env, encoding: 'buffer', cwd: process.cwd() |
35 | }, opts)) |
36 | } |
37 |
Built with git-ssb-web