forked from fluent-ffmpeg/node-fluent-ffmpeg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
40 lines (39 loc) · 13.8 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
"name": "fluent-ffmpeg",
"version": "1.3.2",
"description": "A fluent API to FFMPEG (http://www.ffmpeg.org)",
"keywords": [
"ffmpeg"
],
"author": {
"name": "Stefan Schaermeli",
"email": "[email protected]"
},
"bugs": {
"mail": "[email protected]",
"url": "http://github.com/schaermu/node-fluent-ffmpeg/issues"
},
"repository": {
"type": "git",
"url": "git://github.com/schaermu/node-fluent-ffmpeg.git"
},
"devDependencies": {
"mocha": "latest",
"should": "latest"
},
"dependencies": {
"winston": ">=0.5.10",
"mkdirp": ">= 0.3.4"
},
"engines": {
"node": ">=0.5.0"
},
"main": "index",
"scripts": {
"test": "make test"
},
"readme": "# Fluent ffmpeg-API for node.js [![Build Status](https://secure.travis-ci.org/schaermu/node-fluent-ffmpeg.png)](http://travis-ci.org/schaermu/node-fluent-ffmpeg)\r\nThis library abstracts the complex command-line usage of ffmpeg into a fluent, easy to use node.js module. In order to be able to use this module, make sure you have [ffmpeg](http://www.ffmpeg.org) installed on your system (including all necessary encoding libraries like libmp3lame or libx264).\r\n\r\nNow including input streaming support (means you can convert **on-the-fly** using an input- and an outputstream)!\r\n## Installation\r\nVia npm:\r\n`$ npm install fluent-ffmpeg`\r\n\r\nOr as a submodule:\r\n`$ git submodule add git://github.com/schaermu/node-fluent-ffmpeg.git vendor/fluent-ffmpeg`\r\n## Tests\r\nTo run unit tests, make sure have mocha installed on your system (registered as devDependency in npm config).\r\n\r\n`$ make test`\r\n\r\nIf you want to re-generate the test coverage report (filed under test/coverage.html), run\r\n\r\n`$ make test-cov`\r\n\r\nMake sure your ffmpeg installation is up-to-date to prevent strange assertion errors because of missing codecs/bugfixes.\r\n## Usage\r\nYou find a lot of usage examples (including a real-time streaming example using [flowplayer](http://www.flowplayer.org) and [express](https://github.com/visionmedia/express)!) in the `examples` folder.\r\n## Basics\r\nfluent-ffmpeg is always initialized using the returned class of your initial (and only) require call. You have to supply an config object to the constructor containing at least the input source (either a ReadableStream or a filepath).\r\n\r\n var ffmpeg = require('fluent-ffmpeg');\r\n\r\n var proc = new ffmpeg({\r\n // input source, required\r\n source: '/path/to/your_movie.avi',\r\n // timout of the spawned ffmpeg sub-processes in seconds (optional, defaults to 30)\r\n timeout: 30,\r\n // default priority for all ffmpeg sub-processes (optional, defaults to 0 which is no priorization)\r\n priority: 0,\r\n // set a custom [winston](https://github.com/flatiron/winston) logging instance (optional, default null which will cause fluent-ffmpeg to spawn a winston console logger)\r\n logger: null,\r\n // completely disable logging (optional, defaults to false)\r\n nolog: false\r\n });\r\n\r\n### Auto-calculation of video dimensions\r\nSince ffmpeg does not support dynamic sizing of your movies, fluent-ffmpeg can do this job for you (using it's internal metadata-discovery). The following size formats are allowed to be passed to `withSize`:\r\n\r\n * `320x?` - Fixed width, calculate height\r\n * `?x240` - Fixed height, calculate width\r\n * `50%` - percental resizing\r\n * `320x240` - fixed size (plain ffmpeg way)\r\n\r\n### Auto-padding when converting aspect ratio\r\nUsing fluent-ffmpeg, you can auto-pad any video output when converting the aspect ratio. When converting from 4:3 to 16:9, padding is added to the left/right, when converting from 16:9 to 4:3, padding is added to top/bottom.\r\n\r\n var ffmpeg = require('fluent-ffmpeg');\r\n\r\n var proc = new ffmpeg({ source: '/path/to/your_movie.avi' })\r\n .withAspect('4:3')\r\n .withSize('640x480')\r\n .applyAutopadding(true, 'white')\r\n .saveToFile('/path/to/your_target.avi', function(retcode, error) {\r\n console.log('file has been converted succesfully');\r\n });\r\nThis command will auto-pad your 4:3 output video stream using a white background-color (default is black).\r\n\r\n### Simple conversion using preset\r\nThis example loads up a predefined preset in the preset folder (currently, fluent-ffmpeg ships with presets for DIVX, Flashvideo and Podcast conversions)\r\n\r\n var ffmpeg = require('fluent-ffmpeg');\r\n\r\n var proc = new ffmpeg({ source: '/path/to/your_movie.avi' })\r\n .usingPreset('podcast')\r\n .saveToFile('/path/to/your_target.m4v', function(retcode, error) {\r\n console.log('file has been converted succesfully');\r\n });\r\n### Conversion using chainable API\r\nUsing the chainable API, you are able to perform any operation using FFMPEG. the most common options are implemented using methods, for more advanced usages you can still use the `addOption(s)` method group.\r\n\r\n var ffmpeg = require('fluent-ffmpeg');\r\n \r\n var proc = new ffmpeg({ source: '/path/to/your_movie.avi' })\r\n .withVideoBitrate(1024)\r\n .withVideoCodec('divx')\r\n .withAspect('16:9')\r\n .withFps(24)\r\n .withAudioBitrate('128k')\r\n .withAudioCodec('libmp3lame')\r\n .withAudioChannels(2)\r\n .addOption('-vtag', 'DIVX')\r\n .toFormat('avi')\r\n .saveToFile('/path/to/your_target.avi', function(retcode, error) {\r\n console.log('file has been converted succesfully');\r\n });\r\n### Creating thumbnails from a video file\r\nOne pretty neat feature is the ability of fluent-ffmpeg to generate any amount of thumbnails from your movies. The screenshots are taken at automatically determined timemarks using the following formula: `(duration_in_sec * 0.9) / number_of_thumbnails`.\r\n\r\n var ffmpeg = require('fluent-ffmpeg');\r\n \r\n var proc = new ffmpeg({ source: '/path/to/your_movie.avi' })\r\n .withSize('150x100')\r\n .takeScreenshots(5, '/path/to/thumbnail/folder', function(err, filenames) {\r\n console.log(filenames);\r\n console.log('screenshots were saved');\r\n });\r\n\r\nFor more control, you can also set the timemarks for taking screenshots yourself. Timemarks are percent `50%` or otherwise seconds.\r\n\r\n var ffmpeg = require('fluent-ffmpeg');\r\n \r\n var proc = new ffmpeg({ source: '/path/to/your_movie.avi' })\r\n .withSize('150x100')\r\n .takeScreenshots({\r\n count: 2,\r\n timemarks: [ '0.5', '1' ]\r\n }, '/path/to/thumbnail/folder', function(err, filenames) {\r\n console.log(filenames);\r\n console.log('screenshots were saved');\r\n });\r\n \r\nYou can set the screenshots filename dynamically using following format characters:\r\n\r\n* `%s` - offset in seconds\r\n* `%w` - screenshot width\r\n* `%h` - screenshot height\r\n* `%r` - screenshot resolution ( widthxheight )\r\n* `%f` - input filename\r\n* `%b` - input basename ( filename w/o extension ) \r\n* `%i` - number of screenshot in timemark array ( can be zeropadded by using it like `%000i` ) \r\n\r\nIf multiple timemarks are given and no `%i` format character is found in filename `_%i` will be added to the end of the given filename.\r\n\r\n var ffmpeg = require('fluent-ffmpeg');\r\n\r\n var proc = new ffmpeg({ source: '/path/to/your_movie.avi' })\r\n .withSize('150x100')\r\n .takeScreenshots({\r\n count: 2,\r\n timemarks: [ '50%', '75%' ],\r\n filename: '%b_screenshot_%w_%i'\r\n }, '/path/to/thumbnail/folder', function(err, filenames) {\r\n console.log(filenames);\r\n console.log('screenshots were saved');\r\n });\r\n\r\n### Reading video metadata\r\nUsing a seperate object, you are able to access various metadata of your video file.\r\n\r\n var Metalib = require('fluent-ffmpeg').Metadata;\r\n\r\n // make sure you set the correct path to your video file\r\n var metaObject = new Metalib('/path/to/your_movie.avi');\r\n metaObject.get(function(metadata, err) {\r\n console.log(require('util').inspect(metadata, false, null));\r\n });\r\n\r\n### Reading Codec information while processing\r\nUsing the notification callback onCodecData, you can get informations about the input file's codecs being processed:\r\n\r\n var ffmpeg = require('fluent-ffmpeg');\r\n\r\n var proc = new ffmpeg({ source: '/path/to/your_movie.avi' })\r\n .withAspect('4:3')\r\n .withSize('640x480')\r\n .onCodecData(function(codecinfo) {\r\n console.log(codecinfo);\r\n })\r\n .saveToFile('/path/to/your_target.avi', function(retcode, error) {\r\n console.log('file has been converted succesfully');\r\n });\r\n\r\n### Getting progress notification\r\nYou can set the call back onProgress if you want to be notified on every progress update (triggered as fast as it's written out by FFMPEG).\r\n\r\n var proc = new ffmpeg({ source: '/path/to/your_movie.avi' })\r\n .withAspect('4:3')\r\n .withSize('640x480')\r\n .onProgress(function(progress) {\r\n console.log(progress);\r\n })\r\n .saveToFile('/path/to/your_target.avi', function(retcode, error) {\r\n console.log('file has been converted succesfully');\r\n });\r\n\r\nThe progress object consists of 6 properties:\r\n\r\n * `frames` - the total processed frame count\r\n * `currentFps` - the framerate at which FFMPEG is currently processing the file\r\n * `currentKbps` - the throughput at which FFMPEG is currently processing the file\r\n * `targetSize` - the current size of the target file\r\n * `timemark` - the timestamp of the frame being processed right now\r\n * `percent` - an estimation on the progress (metadata is used, durationsec * fps)\r\n\r\n### Additional Inputs\r\nIn case you need to add, for instance, and audio track\r\n\r\n var ffmpeg = require('fluent-ffmpeg');\r\n\r\n var proc = new ffmpeg({ source: 'images/frame%05d.png' })\r\n .addInput('soundtrack.mp3')\r\n .saveToFile('/path/to/your_target.avi', function(retcode, error) {\r\n console.log('file has been created with soundtrack succesfully');\r\n });\r\n\r\n### Creating a custom preset\r\nTo create a custom preset, you have to create a new file inside the `lib/presets` folder. The filename is used as the preset's name ([presetname].js). In order to make the preset work, you have to export a `load` function using the CommonJS module specifications:\r\n\r\n exports.load = function(ffmpeg) {\r\n // your custom preset code\r\n }\r\n\r\nThe `ffmpeg` parameter is a full fluent-ffmpeg object, you can use all the chaining-goodness from here on. For a good example for the possibilities using presets, check out `lib/presets/podcast.js`.\r\n\r\n\r\n### Setting custom child process niceness\r\nYou can adjust the scheduling priority of the child process used by ffmpeg, using renice (http://manpages.ubuntu.com/manpages/intrepid/man1/renice.1.html):\r\n\r\n var ffmpeg = require('fluent-ffmpeg');\r\n \r\n var proc = new ffmpeg({ source: './source.mp3', priority: 10 })\r\n .withAudioCodec('libvorbis')\r\n .toFormat('ogg')\r\n .saveToFile('./target.ogg', function(retcode, error) {\r\n console.log('file has been converted succesfully');\r\n });\r\n\r\nWhich will use a niceness of 10 (thus it has a lower scheduling priority than the node process and other processes, which default to a niceness of 0).\r\n\r\n### Setting an optional processing timeout\r\nIf you want to know for sure that the ffmpeg child process will not run for longer than a certain amount of time, you can optionally pass the key 'timeout' into the constructor of the ffmpeg command object. An example of a process that will return an error string of 'timeout' if ffmpeg did not finish within 10 minutes:\r\n\r\n var ffmpeg = require('fluent-ffmpeg');\r\n \r\n var proc = new ffmpeg({ source: './source.mp3', timeout: 10 * 60 })\r\n .withAudioCodec('libvorbis')\r\n .toFormat('ogg')\r\n .saveToFile('./target.ogg', function(retcode, error) {\r\n if (retcode == ffmpeg.E_PROCESSTIMEOUT) {\r\n console.log('ffmpeg terminated because of timeout');\r\n }\r\n });\r\n\r\n## Contributors\r\n* [tommadema](http://github.com/tommadema)\r\n* [sadikzzz](http://github.com/sadikzzz)\r\n* [tagedieb](http://github.com/tagedieb)\r\n* [Weltschmerz](http://github.com/Weltschmerz)\r\n* [enobrev](http://github.com/enobrev)\r\n\r\n## Contributing\r\nContributions in any form are highly encouraged and welcome! Be it new or improved presets, optimized streaming code or just some cleanup. So start forking!\r\n\r\n## License\r\n(The MIT License)\r\n\r\nCopyright (c) 2011 Stefan Schaermeli <[email protected]>\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n",
"readmeFilename": "README.md",
"_id": "[email protected]",
"_from": "fluent-ffmpeg@latest"
}