├── .gitignore ├── .travis.yml ├── README.md ├── getbin.sh ├── index.js ├── install.js ├── package.json └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | *.log 4 | ffmpeg/ 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "node" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/konsumer/easy-ffmpeg.svg?branch=master)](https://travis-ci.org/konsumer/easy-ffmpeg) 2 | 3 | This has exactly the same interface as [node-fluent-ffmpeg](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg). It's a thin wrapper that includes binaries for mac, windows, and linux. 4 | 5 | ## installation 6 | 7 | [![Greenkeeper badge](https://badges.greenkeeper.io/konsumer/easy-ffmpeg.svg)](https://greenkeeper.io/) 8 | 9 | You can install it with `npm install easy-ffmpeg` 10 | 11 | ## usage 12 | 13 | If you are already using [fluent-ffmpeg](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg), update your package.json and you are done. 14 | 15 | ```js 16 | const ffmpeg = require('fluent-ffmpeg') 17 | ``` 18 | 19 | to 20 | 21 | ```js 22 | const ffmpeg = require('easy-ffmpeg') 23 | ``` 24 | 25 | ## more info 26 | 27 | Here is where I get my static binaries: 28 | 29 | ```json 30 | { 31 | "linux": { 32 | "ia32": "http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-32bit-static.tar.xz" 33 | }, 34 | 35 | "darwin": { 36 | "x64": "http://evermeet.cx/pub/ffmpeg/ffmpeg-VERSION.7z" 37 | }, 38 | 39 | "win32": { 40 | "ia32": "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-VERSION-win32-static.7z" 41 | } 42 | } 43 | ``` 44 | 45 | If you want to download your own up-to-date versions, use `npm run bin`. You will need curl/7zip/tar binaries in your path, and you will need to be on linux or mac. 46 | -------------------------------------------------------------------------------- /getbin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # this collects the binaries for uploading to releases 4 | # tested on OSX. may work on Linux 5 | # requirements: curl, 7z 6 | 7 | VERSION='2.8.2' 8 | 9 | rm -rf ffmpeg 10 | mkdir -p ffmpeg/linux/ia32 ffmpeg/darwin/x64 ffmpeg/win32/ia32 11 | 12 | cd ffmpeg/linux 13 | curl 'http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-32bit-static.tar.xz' -o ffmpeg-32.tar.xz && 14 | tar xf ffmpeg-32.tar.xz && 15 | mv ffmpeg-*-32bit-static/ffmpeg ffmpeg-*-32bit-static/ffprobe ia32 && 16 | rm -rf ffmpeg-*-*-static *.tar.xz 17 | 18 | cd ../darwin 19 | curl "http://evermeet.cx/pub/ffmpeg/ffmpeg-$VERSION.7z" -o ffmpeg.7z && 20 | curl "http://evermeet.cx/pub/ffprobe/ffprobe-$VERSION.7z" -o ffprobe.7z && 21 | 7z e ffmpeg.7z && 22 | 7z e ffprobe.7z && 23 | mv ffmpeg ffprobe x64 && 24 | rm ffmpeg.7z ffprobe.7z 25 | 26 | cd ../win32 27 | curl "https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-$VERSION-win32-static.7z" -o ffmpeg.7z && 28 | 7z x ffmpeg.7z && 29 | mv ffmpeg-*-win32-static/bin/ffmpeg.exe ffmpeg-*-win32-static/bin/ffprobe.exe ia32 && 30 | rm -rf ffmpeg.7z ffmpeg-*-win32-static 31 | 32 | cd ../.. 33 | tar czf ffmpeg/ffmpeg-linux.tgz ffmpeg/linux/ 34 | tar czf ffmpeg/ffmpeg-darwin.tgz ffmpeg/darwin/ 35 | tar czf ffmpeg/ffmpeg-win32.tgz ffmpeg/win32/ 36 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var FfmpegCommand = require('fluent-ffmpeg') 2 | var path = require('path') 3 | var fs = require('fs') 4 | 5 | // osx: x64 / other: ia32 6 | var arch = process.platform === 'darwin' ? 'x64' : 'ia32' 7 | 8 | // only windows has an extension 9 | var ext = process.platform === 'win32' ? '.exe' : '' 10 | 11 | try { 12 | var ffmpeg = path.join(__dirname, 'ffmpeg', process.platform, arch, 'ffmpeg' + ext) 13 | var ffprobe = path.join(__dirname, 'ffmpeg', process.platform, arch, 'ffprobe' + ext) 14 | // this checks if the ffmpeg folder exists in our repo, if it doesn't it will return an error 15 | fs.accessSync(ffmpeg, fs.F_OK) 16 | fs.accessSync(ffprobe, fs.F_OK) 17 | 18 | // folder exists so we need to load ffmpeg and ffprobe from our repo 19 | FfmpegCommand.setFfmpegPath(ffmpeg) 20 | FfmpegCommand.setFfprobePath(ffprobe) 21 | } catch (e) { 22 | // folder does not exist, this means that ffmpeg and ffprobe 23 | // wore found somewhere else during the install process 24 | // fluent-ffmpeg will set the correct paths on it's own 25 | } 26 | 27 | module.exports = FfmpegCommand 28 | -------------------------------------------------------------------------------- /install.js: -------------------------------------------------------------------------------- 1 | var tarball = require('tarball-extract') 2 | var request = require('request') 3 | var fs = require('fs') 4 | 5 | var user = 'konsumer' 6 | var tag = '0.0.13' 7 | var repoName = 'easy-ffmpeg' 8 | var pkg = 'ffmpeg-' + process.platform + '.tgz' 9 | var counter = 0 10 | var errors = 0 11 | 12 | function downloader () { 13 | // if no ffmpeg and ffprobe are found installed 14 | // we will download the one for our platform 15 | 16 | var url = 'https://github.com/' + user + '/' + repoName + '/releases/download/' + tag + '/' + pkg 17 | 18 | request 19 | .get(url) 20 | .on('error', function (err) { 21 | throw err 22 | }) 23 | .pipe(fs.createWriteStream(pkg)) 24 | .on('close', function () { 25 | tarball.extractTarball(pkg, __dirname, function (err, result) { 26 | if (err) { 27 | throw err 28 | } 29 | fs.unlink(pkg, function (err) { 30 | if (err) { 31 | throw err 32 | } 33 | }) 34 | }) 35 | }) 36 | } 37 | 38 | function checker (err, path) { 39 | if (err) { 40 | errors++ 41 | } else if (!err && !path) { 42 | errors++ 43 | } 44 | 45 | if (counter) { 46 | // finished checking for ffmpeg and ffprobe 47 | if (errors) { 48 | // could not find ffmpeg and ffprobe installed, downloading 49 | downloader() 50 | } 51 | } else { 52 | counter++ 53 | } 54 | } 55 | 56 | // let's try to find ffmpeg and ffprobe 57 | var ffmpeg = require('fluent-ffmpeg')() 58 | 59 | ffmpeg._getFfmpegPath(checker) 60 | ffmpeg._getFfprobePath(checker) 61 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "easy-ffmpeg", 3 | "version": "0.0.15", 4 | "description": "Fluent self-contained interface to ffmpeg", 5 | "main": "index.js", 6 | "keywords": [ 7 | "ffmpeg" 8 | ], 9 | "author": "David Konsumer ", 10 | "license": "MIT", 11 | "devDependencies": {}, 12 | "dependencies": { 13 | "fluent-ffmpeg": "", 14 | "request": "^2.65.0", 15 | "tarball-extract": "0.0.6", 16 | "tar": "6.0.0" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "http://github.com/konsumer/easy-ffmpeg.git" 21 | }, 22 | "bugs": { 23 | "url": "http://github.com/konsumer/easy-ffmpeg/issues", 24 | "email": "konsumer@jetboystudio.com" 25 | }, 26 | "scripts": { 27 | "bin": "./getbin.sh", 28 | "postinstall": "node install.js" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | var ffmpeg = require('./') 2 | 3 | ffmpeg('/Users/konsumer/Desktop/big_buck_bunny.mp4') 4 | .videoFilters('fade=in:0:30') 5 | .videoFilters('pad=640:480:0:40:violet') 6 | .on('end', function () { 7 | console.log('done processing input stream') 8 | }) 9 | .on('error', function (err) { 10 | console.log('an error happened: ' + err.message) 11 | }) 12 | .save('big_buck_bunny.mp4') 13 | --------------------------------------------------------------------------------