{"id":13394052,"url":"https://github.com/fluent-ffmpeg/node-fluent-ffmpeg","last_synced_at":"2025-05-13T20:05:53.249Z","repository":{"id":37759441,"uuid":"1602811","full_name":"fluent-ffmpeg/node-fluent-ffmpeg","owner":"fluent-ffmpeg","description":"A fluent API to FFMPEG (http://www.ffmpeg.org)","archived":false,"fork":false,"pushed_at":"2024-07-23T21:59:25.000Z","size":8973,"stargazers_count":8185,"open_issues_count":419,"forks_count":895,"subscribers_count":130,"default_branch":"master","last_synced_at":"2025-05-06T19:52:10.182Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fluent-ffmpeg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-04-12T06:27:12.000Z","updated_at":"2025-05-06T00:23:01.000Z","dependencies_parsed_at":"2024-08-23T01:20:16.895Z","dependency_job_id":null,"html_url":"https://github.com/fluent-ffmpeg/node-fluent-ffmpeg","commit_stats":{"total_commits":607,"total_committers":100,"mean_commits":6.07,"dds":0.6985172981878089,"last_synced_commit":"fafb8d3a66f91485907145d776cc14272e402f48"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-ffmpeg%2Fnode-fluent-ffmpeg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-ffmpeg%2Fnode-fluent-ffmpeg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-ffmpeg%2Fnode-fluent-ffmpeg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-ffmpeg%2Fnode-fluent-ffmpeg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluent-ffmpeg","download_url":"https://codeload.github.com/fluent-ffmpeg/node-fluent-ffmpeg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020478,"owners_count":22000750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T17:01:07.302Z","updated_at":"2025-05-13T20:05:53.224Z","avatar_url":"https://github.com/fluent-ffmpeg.png","language":"JavaScript","readme":"# Fluent ffmpeg-API for node.js\n\n[![Coverage Status](https://coveralls.io/repos/github/fluent-ffmpeg/node-fluent-ffmpeg/badge.svg?branch=master)](https://coveralls.io/github/fluent-ffmpeg/node-fluent-ffmpeg?branch=master)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Ffluent-ffmpeg%2Fnode-fluent-ffmpeg.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Ffluent-ffmpeg%2Fnode-fluent-ffmpeg?ref=badge_shield)\n\n\u003e **Fluent-ffmpeg is looking for new maintainers**\n\u003e More details [on the wiki](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/wiki/Looking-for-a-new-maintainer)\n\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).\n\n\u003e This is the documentation for fluent-ffmpeg 2.x.\n\u003e You can still access the code and documentation for fluent-ffmpeg 1.7 [here](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/tree/1.x).\n\n## Installation\n\nVia npm:\n\n```sh\n$ npm install fluent-ffmpeg\n```\n\nOr as a submodule:\n```sh\n$ git submodule add git://github.com/schaermu/node-fluent-ffmpeg.git vendor/fluent-ffmpeg\n```\n\n\n\n## Usage\n\nYou will 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.\n\n\n### Prerequisites\n\n#### ffmpeg and ffprobe\n\nfluent-ffmpeg requires ffmpeg \u003e= 0.9 to work.  It may work with previous versions but several features won't be available (and the library is not tested with lower versions anylonger).\n\nIf the `FFMPEG_PATH` environment variable is set, fluent-ffmpeg will use it as the full path to the `ffmpeg` executable.  Otherwise, it will attempt to call `ffmpeg` directly (so it should be in your `PATH`).  You must also have ffprobe installed (it comes with ffmpeg in most distributions).  Similarly, fluent-ffmpeg will use the `FFPROBE_PATH` environment variable if it is set, otherwise it will attempt to call it in the `PATH`.\n\nMost features should work when using avconv and avprobe instead of ffmpeg and ffprobe, but they are not officially supported at the moment.\n\n**Windows users**: most probably ffmpeg and ffprobe will _not_ be in your `%PATH`, so you _must_ set `%FFMPEG_PATH` and `%FFPROBE_PATH`.\n\n**Debian/Ubuntu users**: the official repositories have the ffmpeg/ffprobe executable in the `libav-tools` package, and they are actually rebranded avconv/avprobe executables (avconv is a fork of ffmpeg).  They should be mostly compatible, but should you encounter any issue, you may want to use the real ffmpeg instead.  You can either compile it from source or find a pre-built .deb package at https://ffmpeg.org/download.html (For Ubuntu, the `ppa:mc3man/trusty-media` PPA provides recent builds).\n\n#### flvtool2 or flvmeta\n\nIf you intend to encode FLV videos, you must have either flvtool2 or flvmeta installed and in your `PATH` or fluent-ffmpeg won't be able to produce streamable output files.  If you set either the `FLVTOOL2_PATH` or `FLVMETA_PATH`, fluent-ffmpeg will try to use it instead of searching in the `PATH`.\n\n#### Setting binary paths manually\n\nAlternatively, you may set the ffmpeg, ffprobe and flvtool2/flvmeta binary paths manually by using the following API commands:\n\n* **Ffmpeg.setFfmpegPath(path)** Argument `path` is a string with the full path to the ffmpeg binary.\n* **Ffmpeg.setFfprobePath(path)** Argument `path` is a string with the full path to the ffprobe binary.\n* **Ffmpeg.setFlvtoolPath(path)** Argument `path` is a string with the full path to the flvtool2 or flvmeta binary.\n\n\n### Creating an FFmpeg command\n\nThe fluent-ffmpeg module returns a constructor that you can use to instanciate FFmpeg commands.\n\n```js\nvar FfmpegCommand = require('fluent-ffmpeg');\nvar command = new FfmpegCommand();\n```\n\nYou can also use the constructor without the `new` operator.\n\n```js\nvar ffmpeg = require('fluent-ffmpeg');\nvar command = ffmpeg();\n```\n\nYou may pass an input file name or readable stream, a configuration object, or both to the constructor.\n\n```js\nvar command = ffmpeg('/path/to/file.avi');\nvar command = ffmpeg(fs.createReadStream('/path/to/file.avi'));\nvar command = ffmpeg({ option: \"value\", ... });\nvar command = ffmpeg('/path/to/file.avi', { option: \"value\", ... });\n```\n\nThe following options are available:\n* `source`: input file name or readable stream (ignored if an input file is passed to the constructor)\n* `timeout`: ffmpeg timeout in seconds (defaults to no timeout)\n* `preset` or `presets`: directory to load module presets from (defaults to the `lib/presets` directory in fluent-ffmpeg tree)\n* `niceness` or `priority`: ffmpeg niceness value, between -20 and 20; ignored on Windows platforms (defaults to 0)\n* `logger`: logger object with `debug()`, `info()`, `warn()` and `error()` methods (defaults to no logging)\n* `stdoutLines`: maximum number of lines from ffmpeg stdout/stderr to keep in memory (defaults to 100, use 0 for unlimited storage)\n\n\n### Specifying inputs\n\nYou can add any number of inputs to an Ffmpeg command.  An input can be:\n* a file name (eg. `/path/to/file.avi`);\n* an image pattern (eg. `/path/to/frame%03d.png`);\n* a readable stream; only one input stream may be used for a command, but you can use both an input stream and one or several file names.\n\n```js\n// Note that all fluent-ffmpeg methods are chainable\nffmpeg('/path/to/input1.avi')\n  .input('/path/to/input2.avi')\n  .input(fs.createReadStream('/path/to/input3.avi'));\n\n// Passing an input to the constructor is the same as calling .input()\nffmpeg()\n  .input('/path/to/input1.avi')\n  .input('/path/to/input2.avi');\n\n// Most methods have several aliases, here you may use addInput or mergeAdd instead\nffmpeg()\n  .addInput('/path/to/frame%02d.png')\n  .addInput('/path/to/soundtrack.mp3');\n\nffmpeg()\n  .mergeAdd('/path/to/input1.avi')\n  .mergeAdd('/path/to/input2.avi');\n```\n\n\n### Input options\n\nThe following methods enable passing input-related options to ffmpeg.  Each of these methods apply on the last input added (including the one passed to the constructor, if any).  You must add an input before calling those, or an error will be thrown.\n\n#### inputFormat(format): specify input format\n\n**Aliases**: `fromFormat()`, `withInputFormat()`.\n\nThis is only useful for raw inputs, as ffmpeg can determine the input format automatically.\n\n```js\nffmpeg()\n  .input('/dev/video0')\n  .inputFormat('mov')\n  .input('/path/to/file.avi')\n  .inputFormat('avi');\n```\n\nFluent-ffmpeg checks for format availability before actually running the command, and throws an error when a specified input format is not available.\n\n#### inputFPS(fps): specify input framerate\n\n**Aliases**: `withInputFps()`, `withInputFPS()`, `withFpsInput()`, `withFPSInput()`, `inputFps()`, `fpsInput()`, `FPSInput()`.\n\nThis is only valid for raw inputs, as ffmpeg can determine the input framerate automatically.\n\n```js\nffmpeg('/dev/video0').inputFPS(29.7);\n```\n\n#### native(): read input at native framerate\n\n**Aliases**: `nativeFramerate()`, `withNativeFramerate()`.\n\n```js\nffmpeg('/path/to/file.avi').native();\n```\n\n#### seekInput(time): set input start time\n\n**Alias**: `setStartTime()`.\n\nSeeks an input and only start decoding at given time offset.  The `time` argument may be a number (in seconds) or a timestamp string (with format `[[hh:]mm:]ss[.xxx]`).\n\n```js\nffmpeg('/path/to/file.avi').seekInput(134.5);\nffmpeg('/path/to/file.avi').seekInput('2:14.500');\n```\n\n#### loop([duration]): loop over input\n\n```js\nffmpeg('/path/to/file.avi').loop();\nffmpeg('/path/to/file.avi').loop(134.5);\nffmpeg('/path/to/file.avi').loop('2:14.500');\n```\n\n#### inputOptions(option...): add custom input options\n\n**Aliases**: `inputOption()`, `addInputOption()`, `addInputOptions()`, `withInputOption()`, `withInputOptions()`.\n\nThis method allows passing any input-related option to ffmpeg.  You can call it with a single argument to pass a single option, optionally with a space-separated parameter:\n\n```js\n/* Single option */\nffmpeg('/path/to/file.avi').inputOptions('-someOption');\n\n/* Single option with parameter */\nffmpeg('/dev/video0').inputOptions('-r 24');\n```\n\nYou may also pass multiple options at once by passing an array to the method:\n\n```js\nffmpeg('/path/to/file.avi').inputOptions([\n  '-option1',\n  '-option2 param2',\n  '-option3',\n  '-option4 param4'\n]);\n```\n\nFinally, you may also directly pass command line tokens as separate arguments to the method:\n\n```js\nffmpeg('/path/to/file.avi').inputOptions(\n  '-option1',\n  '-option2', 'param2',\n  '-option3',\n  '-option4', 'param4'\n);\n```\n\n\n### Audio options\n\nThe following methods change the audio stream(s) in the produced output.\n\n#### noAudio(): disable audio altogether\n\n**Aliases**: `withNoAudio()`.\n\nDisables audio in the output and remove any previously set audio option.\n\n```js\nffmpeg('/path/to/file.avi').noAudio();\n```\n\n#### audioCodec(codec): set audio codec\n\n**Aliases**: `withAudioCodec()`.\n\n```js\nffmpeg('/path/to/file.avi').audioCodec('libmp3lame');\n```\n\nFluent-ffmpeg checks for codec availability before actually running the command, and throws an error when a specified audio codec is not available.\n\n#### audioBitrate(bitrate): set audio bitrate\n\n**Aliases**: `withAudioBitrate()`.\n\nSets the audio bitrate in kbps.  The `bitrate` parameter may be a number or a string with an optional `k` suffix.  This method is used to enforce a constant bitrate; use `audioQuality()` to encode using a variable bitrate.\n\n```js\nffmpeg('/path/to/file.avi').audioBitrate(128);\nffmpeg('/path/to/file.avi').audioBitrate('128');\nffmpeg('/path/to/file.avi').audioBitrate('128k');\n```\n\n#### audioChannels(count): set audio channel count\n\n**Aliases**: `withAudioChannels()`.\n\n```js\nffmpeg('/path/to/file.avi').audioChannels(2);\n```\n\n#### audioFrequency(freq): set audio frequency\n\n**Aliases**: `withAudioFrequency()`.\n\nThe `freq` parameter specifies the audio frequency in Hz.\n\n```js\nffmpeg('/path/to/file.avi').audioFrequency(22050);\n```\n\n#### audioQuality(quality): set audio quality\n\n**Aliases**: `withAudioQuality()`.\n\nThis method fixes a quality factor for the audio codec (VBR encoding).  The quality scale depends on the actual codec used.\n\n```js\nffmpeg('/path/to/file.avi')\n  .audioCodec('libmp3lame')\n  .audioQuality(0);\n```\n\n#### audioFilters(filter...): add custom audio filters\n\n**Aliases**: `audioFilter()`, `withAudioFilter()`, `withAudioFilters()`.\n\nThis method enables adding custom audio filters.  You may add multiple filters at once by passing either several arguments or an array.  See the Ffmpeg documentation for available filters and their syntax.\n\nEach filter pased to this method can be either a filter string (eg. `volume=0.5`) or a filter specification object with the following keys:\n* `filter`: filter name\n* `options`: optional; either an option string for the filter (eg. `n=-50dB:d=5`), an options array for unnamed options (eg. `['-50dB', 5]`) or an object mapping option names to values (eg. `{ n: '-50dB', d: 5 }`).  When `options` is not specified, the filter will be added without any options.\n\n```js\nffmpeg('/path/to/file.avi')\n  .audioFilters('volume=0.5')\n  .audioFilters('silencedetect=n=-50dB:d=5');\n\nffmpeg('/path/to/file.avi')\n  .audioFilters('volume=0.5', 'silencedetect=n=-50dB:d=5');\n\nffmpeg('/path/to/file.avi')\n  .audioFilters(['volume=0.5', 'silencedetect=n=-50dB:d=5']);\n\nffmpeg('/path/to/file.avi')\n  .audioFilters([\n    {\n      filter: 'volume',\n      options: '0.5'\n    },\n    {\n      filter: 'silencedetect',\n      options: 'n=-50dB:d=5'\n    }\n  ]);\n\nffmpeg('/path/to/file.avi')\n  .audioFilters(\n    {\n      filter: 'volume',\n      options: ['0.5']\n    },\n    {\n      filter: 'silencedetect',\n      options: { n: '-50dB', d: 5 }\n    }\n  ]);\n```\n\n\n### Video options\n\nThe following methods change the video stream(s) in the produced output.\n\n#### noVideo(): disable video altogether\n\n**Aliases**: `withNoVideo()`.\n\nThis method disables video output and removes any previously set video option.\n\n```js\nffmpeg('/path/to/file.avi').noVideo();\n```\n\n#### videoCodec(codec): set video codec\n\n**Aliases**: `withVideoCodec()`.\n\n```js\nffmpeg('/path/to/file.avi').videoCodec('libx264');\n```\n\nFluent-ffmpeg checks for codec availability before actually running the command, and throws an error when a specified video codec is not available.\n\n#### videoBitrate(bitrate[, constant=false]): set video bitrate\n\n**Aliases**: `withVideoBitrate()`.\n\nSets the target video bitrate in kbps.  The `bitrate` argument may be a number or a string with an optional `k` suffix.  The `constant` argument specifies whether a constant bitrate should be enforced (defaults to false).\n\nKeep in mind that, depending on the codec used, enforcing a constant bitrate often comes at the cost of quality.  The best way to have a constant video bitrate without losing too much quality is to use 2-pass encoding (see Fffmpeg documentation).\n\n```js\nffmpeg('/path/to/file.avi').videoBitrate(1000);\nffmpeg('/path/to/file.avi').videoBitrate('1000');\nffmpeg('/path/to/file.avi').videoBitrate('1000k');\nffmpeg('/path/to/file.avi').videoBitrate('1000k', true);\n```\n\n#### videoFilters(filter...): add custom video filters\n\n**Aliases**: `videoFilter()`, `withVideoFilter()`, `withVideoFilters()`.\n\nThis method enables adding custom video filters.  You may add multiple filters at once by passing either several arguments or an array.  See the Ffmpeg documentation for available filters and their syntax.\n\nEach filter pased to this method can be either a filter string (eg. `fade=in:0:30`) or a filter specification object with the following keys:\n* `filter`: filter name\n* `options`: optional; either an option string for the filter (eg. `in:0:30`), an options array for unnamed options (eg. `['in', 0, 30]`) or an object mapping option names to values (eg. `{ t: 'in', s: 0, n: 30 }`).  When `options` is not specified, the filter will be added without any options.\n\n```js\nffmpeg('/path/to/file.avi')\n  .videoFilters('fade=in:0:30')\n  .videoFilters('pad=640:480:0:40:violet');\n\nffmpeg('/path/to/file.avi')\n  .videoFilters('fade=in:0:30', 'pad=640:480:0:40:violet');\n\nffmpeg('/path/to/file.avi')\n  .videoFilters(['fade=in:0:30', 'pad=640:480:0:40:violet']);\n\nffmpeg('/path/to/file.avi')\n  .videoFilters([\n    {\n      filter: 'fade',\n      options: 'in:0:30'\n    },\n    {\n      filter: 'pad',\n      options: '640:480:0:40:violet'\n    }\n  ]);\n\nffmpeg('/path/to/file.avi')\n    .videoFilters(\n    {\n      filter: 'fade',\n      options: ['in', 0, 30]\n    },\n    {\n      filter: 'filter2',\n      options: { w: 640, h: 480, x: 0, y: 40, color: 'violet' }\n    }\n  );\n```\n\n#### fps(fps): set output framerate\n\n**Aliases**: `withOutputFps()`, `withOutputFPS()`, `withFpsOutput()`, `withFPSOutput()`, `withFps()`, `withFPS()`, `outputFPS()`, `outputFps()`, `fpsOutput()`, `FPSOutput()`, `FPS()`.\n\n```js\nffmpeg('/path/to/file.avi').fps(29.7);\n```\n\n#### frames(count): specify frame count\n\n**Aliases**: `takeFrames()`, `withFrames()`.\n\nSet ffmpeg to only encode a certain number of frames.\n\n```js\nffmpeg('/path/to/file.avi').frames(240);\n```\n\n\n### Video frame size options\n\nThe following methods enable resizing the output video frame size.  They all work together to generate the appropriate video filters.\n\n#### size(size): set output frame size\n\n**Aliases**: `videoSize()`, `withSize()`.\n\nThis method sets the output frame size.  The `size` argument may have one of the following formats:\n* `640x480`: set a fixed output frame size.  Unless `autopad()` is called, this may result in the video being stretched or squeezed to fit the requested size.\n* `640x?`: set a fixed width and compute height automatically.  If `aspect()` is also called, it is used to compute video height; otherwise it is computed so that the input aspect ratio is preserved.\n* `?x480`: set a fixed height and compute width automatically.  If `aspect()` is also called, it is used to compute video width; otherwise it is computed so that the input aspect ratio is preserved.\n* `50%`: rescale both width and height to the given percentage.  Aspect ratio is always preserved.\n\nNote that for compatibility with some codecs, computed dimensions are always rounded down to multiples of 2.\n\n```js\nffmpeg('/path/to/file.avi').size('640x480');\nffmpeg('/path/to/file.avi').size('640x?');\nffmpeg('/path/to/file.avi').size('640x?').aspect('4:3');\nffmpeg('/path/to/file.avi').size('50%');\n```\n\n#### aspect(aspect): set output frame aspect ratio\n\n**Aliases**: `withAspect()`, `withAspectRatio()`, `setAspect()`, `setAspectRatio()`, `aspectRatio()`.\n\nThis method enforces a specific output aspect ratio.  The `aspect` argument may either be a number or a `X:Y` string.\n\nNote that calls to `aspect()` are ignored when `size()` has been called with a fixed width and height or a percentage, and also when `size()` has not been called at all.\n\n```js\nffmpeg('/path/to/file.avi').size('640x?').aspect('4:3');\nffmpeg('/path/to/file.avi').size('640x?').aspect(1.33333);\n```\n\n#### autopad([color='black']): enable auto-padding the output video\n\n**Aliases**: `applyAutopadding()`, `applyAutoPadding()`, `applyAutopad()`, `applyAutoPad()`, `withAutopadding()`, `withAutoPadding()`, `withAutopad()`, `withAutoPad()`, `autoPad()`.\n\nThis method enables applying auto-padding to the output video.  The `color` parameter specifies which color to use for padding, and must be a color code or name supported by ffmpeg (defaults to 'black').\n\nThe behaviour of this method depends on calls made to other video size methods:\n* when `size()` has been called with a percentage or has not been called, it is ignored;\n* when `size()` has been called with `WxH`, it adds padding so that the input aspect ratio is kept;\n* when `size()` has been called with either `Wx?` or `?xH`, padding is only added if `aspect()` was called (otherwise the output dimensions are computed from the input aspect ratio and padding is not needed).\n\n```js\n// No size specified, autopad() is ignored\nffmpeg('/path/to/file.avi').autopad();\n\n// Adds padding to keep original aspect ratio.\n// - with a 640x400 input, 40 pixels of padding are added on both sides\n// - with a 600x480 input, 20 pixels of padding are added on top and bottom\n// - with a 320x200 input, video is scaled up to 640x400 and 40px of padding\n//   is added on both sides\n// - with a 320x240 input, video is scaled up to 640x480 and and no padding\n//   is needed\nffmpeg('/path/to/file.avi').size('640x480').autopad();\nffmpeg('/path/to/file.avi').size('640x480').autopad('white');\nffmpeg('/path/to/file.avi').size('640x480').autopad('#35A5FF');\n\n// Size computed from input, autopad() is ignored\nffmpeg('/path/to/file.avi').size('50%').autopad();\nffmpeg('/path/to/file.avi').size('640x?').autopad();\nffmpeg('/path/to/file.avi').size('?x480').autopad();\n\n// Calling .size('640x?').aspect('4:3') is similar to calling .size('640x480')\n// - with a 640x400 input, 40 pixels of padding are added on both sides\n// - with a 600x480 input, 20 pixels of padding are added on top and bottom\n// - with a 320x200 input, video is scaled up to 640x400 and 40px of padding\n//   is added on both sides\n// - with a 320x240 input, video is scaled up to 640x480 and and no padding\n//   is needed\nffmpeg('/path/to/file.avi').size('640x?').aspect('4:3').autopad();\nffmpeg('/path/to/file.avi').size('640x?').aspect('4:3').autopad('white');\nffmpeg('/path/to/file.avi').size('640x?').aspect('4:3').autopad('#35A5FF');\n\n// Calling .size('?x480').aspect('4:3') is similar to calling .size('640x480')\nffmpeg('/path/to/file.avi').size('?x480').aspect('4:3').autopad();\nffmpeg('/path/to/file.avi').size('?x480').aspect('4:3').autopad('white');\nffmpeg('/path/to/file.avi').size('?x480').aspect('4:3').autopad('#35A5FF');\n```\n\nFor compatibility with previous fluent-ffmpeg versions, this method also accepts an additional boolean first argument, which specifies whether to apply auto-padding.\n\n```js\nffmpeg('/path/to/file.avi').size('640x480').autopad(true);\nffmpeg('/path/to/file.avi').size('640x480').autopad(true, 'pink');\n```\n\n#### keepDAR(): force keeping display aspect ratio\n\n**Aliases**: `keepPixelAspect()`, `keepDisplayAspect()`, `keepDisplayAspectRatio()`.\n\nThis method is useful when converting an input with non-square pixels to an output format that does not support non-square pixels (eg. most image formats).  It rescales the input so that the display aspect ratio is the same.\n\n```js\nffmpeg('/path/to/file.avi').keepDAR();\n```\n\n### Specifying multiple outputs\n\n#### output(target[, options]): add an output to the command\n\n**Aliases**: `addOutput()`.\n\nAdds an output to the command.  The `target` argument may be an output filename or a writable stream (but at most one output stream may be used with a single command).\n\nWhen `target` is a stream, an additional `options` object may be passed.  If it is present, it will be passed ffmpeg output stream `pipe()` method.\n\nAdding an output switches the \"current output\" of the command, so that any fluent-ffmpeg method that applies to an output is indeed applied to the last output added.  For backwards compatibility reasons, you may as well call those methods _before_ adding the first output (in which case they will apply to the first output when it is added).  Methods that apply to an output are all non-input-related methods, except for `complexFilter()`, which is global.\n\nAlso note that when calling `output()`, you should not use the `save()` or `stream()` (formerly `saveToFile()` and `writeToStream()`) methods, as they already add an output.  Use the `run()` method to start processing.\n\n```js\nvar stream  = fs.createWriteStream('outputfile.divx');\n\nffmpeg('/path/to/file.avi')\n  .output('outputfile.mp4')\n  .output(stream);\n\nffmpeg('/path/to/file.avi')\n  // You may pass a pipe() options object when using a stream\n  .output(stream, { end:true });\n\n// Output-related methods apply to the last output added\nffmpeg('/path/to/file.avi')\n\n  .output('outputfile.mp4')\n  .audioCodec('libfaac')\n  .videoCodec('libx264')\n  .size('320x200')\n\n  .output(stream)\n  .preset('divx')\n  .size('640x480');\n\n// Use the run() method to run commands with multiple outputs\nffmpeg('/path/to/file.avi')\n  .output('outputfile.mp4')\n  .output(stream)\n  .on('end', function() {\n    console.log('Finished processing');\n  })\n  .run();\n```\n\n\n### Output options\n\n#### duration(time): set output duration\n\n**Aliases**: `withDuration()`, `setDuration()`.\n\nForces ffmpeg to stop transcoding after a specific output duration.  The `time` parameter may be a number (in seconds) or a timestamp string (with format `[[hh:]mm:]ss[.xxx]`).\n\n```js\nffmpeg('/path/to/file.avi').duration(134.5);\nffmpeg('/path/to/file.avi').duration('2:14.500');\n```\n\n#### seek(time): seek output\n\n**Aliases**: `seekOutput()`.\n\nSeeks streams before encoding them into the output.  This is different from calling `seekInput()` in that the offset will only apply to one output.  This is also slower, as skipped frames will still be decoded (but dropped).\n\nThe `time` argument may be a number (in seconds) or a timestamp string (with format `[[hh:]mm:]ss[.xxx]`).\n\n```js\nffmpeg('/path/to/file.avi')\n  .seekInput('1:00')\n\n  .output('from-1m30s.avi')\n  .seek(30)\n\n  .output('from-1m40s.avi')\n  .seek('0:40');\n```\n\n#### format(format): set output format\n\n**Aliases**: `withOutputFormat()`, `toFormat()`, `outputFormat()`.\n\n```js\nffmpeg('/path/to/file.avi').format('flv');\n```\n\n#### flvmeta(): update FLV metadata after transcoding\n\n**Aliases**: `updateFlvMetadata()`.\n\nCalling this method makes fluent-ffmpeg run `flvmeta` or `flvtool2` on the output file to add FLV metadata and make files streamable.  It does not work when outputting to a stream, and is only useful when outputting to FLV format.\n\n```js\nffmpeg('/path/to/file.avi').flvmeta().format('flv');\n```\n\n#### outputOptions(option...): add custom output options\n\n**Aliases**: `outputOption()`, `addOutputOption()`, `addOutputOptions()`, `withOutputOption()`, `withOutputOptions()`, `addOption()`, `addOptions()`.\n\nThis method allows passing any output-related option to ffmpeg.  You can call it with a single argument to pass a single option, optionally with a space-separated parameter:\n\n```js\n/* Single option */\nffmpeg('/path/to/file.avi').outputOptions('-someOption');\n\n/* Single option with parameter */\nffmpeg('/dev/video0').outputOptions('-r 24');\n```\n\nYou may also pass multiple options at once by passing an array to the method:\n\n```js\nffmpeg('/path/to/file.avi').outputOptions([\n  '-option1',\n  '-option2 param2',\n  '-option3',\n  '-option4 param4'\n]);\n```\n\nFinally, you may also directly pass command line tokens as separate arguments to the method:\n\n```js\nffmpeg('/path/to/file.avi').outputOptions(\n  '-option1',\n  '-option2', 'param2',\n  '-option3',\n  '-option4', 'param4'\n);\n```\n\n\n### Miscellaneous options\n\n#### preset(preset): use fluent-ffmpeg preset\n\n**Aliases**: `usingPreset()`.\n\nThere are two kinds of presets supported by fluent-ffmpeg.  The first one is preset modules; to use those, pass the preset name as the `preset` argument.  Preset modules are loaded from the directory specified by the `presets` constructor option (defaults to the `lib/presets` fluent-ffmpeg subdirectory).\n\n```js\n// Uses \u003cpath-to-fluent-ffmpeg\u003e/lib/presets/divx.js\nffmpeg('/path/to/file.avi').preset('divx');\n\n// Uses /my/presets/foo.js\nffmpeg('/path/to/file.avi', { presets: '/my/presets' }).preset('foo');\n```\n\nPreset modules must export a `load()` function that takes an FfmpegCommand as an argument.   fluent-ffmpeg comes with the following preset modules preinstalled:\n\n* `divx`\n* `flashvideo`\n* `podcast`\n\nHere is the code from the included `divx` preset as an example:\n\n```js\nexports.load = function(ffmpeg) {\n  ffmpeg\n    .format('avi')\n    .videoBitrate('1024k')\n    .videoCodec('mpeg4')\n    .size('720x?')\n    .audioBitrate('128k')\n    .audioChannels(2)\n    .audioCodec('libmp3lame')\n    .outputOptions(['-vtag DIVX']);\n};\n```\n\nThe second kind of preset is preset functions.  To use those, pass a function which takes an FfmpegCommand as a parameter.\n\n```js\nfunction myPreset(command) {\n  command.format('avi').size('720x?');\n}\n\nffmpeg('/path/to/file.avi').preset(myPreset);\n```\n\n#### complexFilter(filters[, map]): set complex filtergraph\n\n**Aliases**: `filterGraph()`\n\nThe `complexFilter()` method enables setting a complex filtergraph for a command.  It expects a filter specification (or a filter specification array) and an optional output mapping parameter as arguments.\n\nFilter specifications may be either plain ffmpeg filter strings (eg. `split=3[a][b][c]`) or objects with the following keys:\n* `filter`: filter name\n* `options`: optional; either an option string for the filter (eg. `in:0:30`), an options array for unnamed options (eg. `['in', 0, 30]`) or an object mapping option names to values (eg. `{ t: 'in', s: 0, n: 30 }`).  When `options` is not specified, the filter will be added without any options.\n* `inputs`: optional; input stream specifier(s) for the filter.  The value may be either a single stream specifier string or an array of stream specifiers.  Each specifier can be optionally enclosed in square brackets.  When input streams are not specified, ffmpeg will use the first unused streams of the correct type.\n* `outputs`: optional; output stream specifier(s) for the filter.  The value may be either a single stream specifier string or an array of stream specifiers.  Each specifier can be optionally enclosed in square brackets.\n\nThe output mapping parameter specifies which stream(s) to include in the output from the filtergraph.  It may be either a single stream specifier string or an array of stream specifiers.  Each specifier can be optionally enclosed in square brackets.  When this parameter is not present, ffmpeg will default to saving all unused outputs to the output file.\n\nNote that only one complex filtergraph may be set on a given command.  Calling `complexFilter()` again will override any previously set filtergraph, but you can set as many filters as needed in a single call.\n\n```js\nffmpeg('/path/to/file.avi')\n  .complexFilter([\n    // Rescale input stream into stream 'rescaled'\n    'scale=640:480[rescaled]',\n\n    // Duplicate rescaled stream 3 times into streams a, b, and c\n    {\n      filter: 'split', options: '3',\n      inputs: 'rescaled', outputs: ['a', 'b', 'c']\n    },\n\n    // Create stream 'red' by removing green and blue channels from stream 'a'\n    {\n      filter: 'lutrgb', options: { g: 0, b: 0 },\n      inputs: 'a', outputs: 'red'\n    },\n\n    // Create stream 'green' by removing red and blue channels from stream 'b'\n    {\n      filter: 'lutrgb', options: { r: 0, b: 0 },\n      inputs: 'b', outputs: 'green'\n    },\n\n    // Create stream 'blue' by removing red and green channels from stream 'c'\n    {\n      filter: 'lutrgb', options: { r: 0, g: 0 },\n      inputs: 'c', outputs: 'blue'\n    },\n\n    // Pad stream 'red' to 3x width, keeping the video on the left,\n    // and name output 'padded'\n    {\n      filter: 'pad', options: { w: 'iw*3', h: 'ih' },\n      inputs: 'red', outputs: 'padded'\n    },\n\n    // Overlay 'green' onto 'padded', moving it to the center,\n    // and name output 'redgreen'\n    {\n      filter: 'overlay', options: { x: 'w', y: 0 },\n      inputs: ['padded', 'green'], outputs: 'redgreen'\n    },\n\n    // Overlay 'blue' onto 'redgreen', moving it to the right\n    {\n      filter: 'overlay', options: { x: '2*w', y: 0 },\n      inputs: ['redgreen', 'blue'], outputs: 'output'\n    },\n  ], 'output');\n```\n\n\n### Setting event handlers\n\nBefore actually running a command, you may want to set event listeners on it to be notified when it's done.  The following events are available:\n\n#### 'start': ffmpeg process started\n\nThe `start` event is emitted just after ffmpeg has been spawned.  It is emitted with the full command line used as an argument.\n\n```js\nffmpeg('/path/to/file.avi')\n  .on('start', function(commandLine) {\n    console.log('Spawned Ffmpeg with command: ' + commandLine);\n  });\n```\n\n#### 'codecData': input codec data available\n\nThe `codecData` event is emitted when ffmpeg outputs codec information about its input streams.  It is emitted with an object argument with the following keys:\n* `format`: input format\n* `duration`: input duration\n* `audio`: audio codec\n* `audio_details`: audio encoding details\n* `video`: video codec\n* `video_details`: video encoding details\n\n```js\nffmpeg('/path/to/file.avi')\n  .on('codecData', function(data) {\n    console.log('Input is ' + data.audio + ' audio ' +\n      'with ' + data.video + ' video');\n  });\n```\n\n#### 'progress': transcoding progress information\n\nThe `progress` event is emitted every time ffmpeg reports progress information.  It is emitted with an object argument with the following keys:\n* `frames`: total processed frame count\n* `currentFps`: framerate at which FFmpeg is currently processing\n* `currentKbps`: throughput at which FFmpeg is currently processing\n* `targetSize`: current size of the target file in kilobytes\n* `timemark`: the timestamp of the current frame in seconds\n* `percent`: an estimation of the progress percentage\n\nNote that `percent` can be (very) inaccurate, as the only progress information fluent-ffmpeg gets from ffmpeg is the total number of frames written (and the corresponding duration).  To estimate percentage, fluent-ffmpeg has to guess what the total output duration will be, and uses the first input added to the command to do so.  In particular:\n* percentage is not available when using an input stream\n* percentage may be wrong when using multiple inputs with different durations and the first one is not the longest\n\n```js\nffmpeg('/path/to/file.avi')\n  .on('progress', function(progress) {\n    console.log('Processing: ' + progress.percent + '% done');\n  });\n```\n\n#### 'stderr': FFmpeg output\n\nThe `stderr` event is emitted every time FFmpeg outputs a line to `stderr`.  It is emitted with a string containing the line of stderr (minus trailing new line characters).\n\n```js\nffmpeg('/path/to/file.avi')\n  .on('stderr', function(stderrLine) {\n    console.log('Stderr output: ' + stderrLine);\n  });\n```\n\n#### 'error': transcoding error\n\nThe `error` event is emitted when an error occurs when running ffmpeg or when preparing its execution.  It is emitted with an error object as an argument.  If the error happened during ffmpeg execution, listeners will also receive two additional arguments containing ffmpegs stdout and stderr.\n\nIf streams are used for input or output, any errors emitted from these streams will be passed through to this event, attached to the `error` as `inputStreamError` and `outputStreamError` for input and output streams respectively.\n\n**Warning**: you should _always_ set a handler for the `error` event, as node's default behaviour when an `error` event without any listeners is emitted is to output the error to the console and _terminate the program_.\n\n```js\nffmpeg('/path/to/file.avi')\n  .on('error', function(err, stdout, stderr) {\n    console.log('Cannot process video: ' + err.message);\n  });\n```\n\n#### 'end': processing finished\n\nThe `end` event is emitted when processing has finished.  Listeners receive ffmpeg standard output and standard error as arguments, except when generating thumbnails (see below), in which case they receive an array of the generated filenames.\n\n```js\nffmpeg('/path/to/file.avi')\n  .on('end', function(stdout, stderr) {\n    console.log('Transcoding succeeded !');\n  });\n```\n\n`stdout` is empty when the command outputs to a stream.  Both `stdout` and `stderr` are limited by the `stdoutLines` option (defaults to 100 lines).\n\n\n### Starting FFmpeg processing\n\n#### save(filename): save the output to a file\n\n**Aliases**: `saveToFile()`\n\nStarts ffmpeg processing and saves the output to a file.\n\n```js\nffmpeg('/path/to/file.avi')\n  .videoCodec('libx264')\n  .audioCodec('libmp3lame')\n  .size('320x240')\n  .on('error', function(err) {\n    console.log('An error occurred: ' + err.message);\n  })\n  .on('end', function() {\n    console.log('Processing finished !');\n  })\n  .save('/path/to/output.mp4');\n```\n\nNote: the `save()` method is actually syntactic sugar for calling both `output()` and `run()`.\n\n#### pipe([stream], [options]): pipe the output to a writable stream\n\n**Aliases**: `stream()`, `writeToStream()`.\n\nStarts processing and pipes ffmpeg output to a writable stream.  The `options` argument, if present, is passed to ffmpeg output stream's `pipe()` method (see nodejs documentation).\n\n```js\nvar outStream = fs.createWriteStream('/path/to/output.mp4');\n\nffmpeg('/path/to/file.avi')\n  .videoCodec('libx264')\n  .audioCodec('libmp3lame')\n  .size('320x240')\n  .on('error', function(err) {\n    console.log('An error occurred: ' + err.message);\n  })\n  .on('end', function() {\n    console.log('Processing finished !');\n  })\n  .pipe(outStream, { end: true });\n```\n\nWhen no `stream` argument is present, the `pipe()` method returns a PassThrough stream, which you can pipe to somewhere else (or just listen to events on).\n\n**Note**: this is only available with node \u003e= 0.10.\n\n```js\nvar command = ffmpeg('/path/to/file.avi')\n  .videoCodec('libx264')\n  .audioCodec('libmp3lame')\n  .size('320x240')\n  .on('error', function(err) {\n    console.log('An error occurred: ' + err.message);\n  })\n  .on('end', function() {\n    console.log('Processing finished !');\n  });\n\nvar ffstream = command.pipe();\nffstream.on('data', function(chunk) {\n  console.log('ffmpeg just wrote ' + chunk.length + ' bytes');\n});\n```\n\nNote: the `stream()` method is actually syntactic sugar for calling both `output()` and `run()`.\n\n#### run(): start processing\n\n**Aliases**: `exec()`, `execute()`.\n\nThis method is mainly useful when producing multiple outputs (otherwise the `save()` or `stream()` methods are more straightforward).  It starts processing with the specified outputs.\n\n**Warning**: do not use `run()` when calling other processing methods (eg. `save()`, `pipe()` or `screenshots()`).\n\n```js\nffmpeg('/path/to/file.avi')\n  .output('screenshot.png')\n  .noAudio()\n  .seek('3:00')\n\n  .output('small.avi')\n  .audioCodec('copy')\n  .size('320x200')\n\n  .output('big.avi')\n  .audioCodec('copy')\n  .size('640x480')\n\n  .on('error', function(err) {\n    console.log('An error occurred: ' + err.message);\n  })\n  .on('end', function() {\n    console.log('Processing finished !');\n  })\n  .run();\n```\n\n#### mergeToFile(filename, tmpdir): concatenate multiple inputs\n\nUse the `input` and `mergeToFile` methods on a command to concatenate multiple inputs to a single output file.  The `mergeToFile` needs a temporary folder as its second argument.\n\n```js\nffmpeg('/path/to/part1.avi')\n  .input('/path/to/part2.avi')\n  .input('/path/to/part2.avi')\n  .on('error', function(err) {\n    console.log('An error occurred: ' + err.message);\n  })\n  .on('end', function() {\n    console.log('Merging finished !');\n  })\n  .mergeToFile('/path/to/merged.avi', '/path/to/tempDir');\n```\n\n#### screenshots(options[, dirname]): generate thumbnails\n\n**Aliases**: `thumbnail()`, `thumbnails()`, `screenshot()`, `takeScreenshots()`.\n\nUse the `screenshots` method to extract one or several thumbnails and save them as PNG files.  There are a few caveats with this implementation, though:\n\n* It will not work on input streams.\n* Progress information reported by the `progress` event is not accurate.\n* It doesn't interract well with filters.  In particular, don't use the `size()` method to resize thumbnails, use the `size` option instead.\n\nThe `options` argument is an object with the following keys:\n\n* `folder`: output folder for generated image files.  Defaults to the current folder.\n* `filename`: output filename pattern (see below).  Defaults to \"tn.png\".\n* `count`: specifies how many thumbnails to generate.  When using this option, thumbnails are generated at regular intervals in the video (for example, when requesting 3 thumbnails, at 25%, 50% and 75% of the video length).  `count` is ignored when `timemarks` or `timestamps` is specified.\n* `timemarks` or `timestamps`: specifies an array of timestamps in the video where thumbnails should be taken.  Each timestamp may be a number (in seconds), a percentage string (eg. \"50%\") or a timestamp string with format \"hh:mm:ss.xxx\" (where hours, minutes and milliseconds are both optional).\n* `size`: specifies a target size for thumbnails (with the same format as the `.size()` method). **Note:** you should not use the `.size()` method when generating thumbnails.\n\nThe `filename` option specifies a filename pattern for generated files.  It may contain the following format tokens:\n\n* '%s': offset in seconds\n* '%w': screenshot width\n* '%h': screenshot height\n* '%r': screenshot resolution (same as '%wx%h')\n* '%f': input filename\n* '%b': input basename (filename w/o extension)\n* '%i': index of screenshot in timemark array (can be zero-padded by using it like `%000i`)\n\nIf multiple timemarks are passed and no variable format token ('%s' or '%i') is specified in the filename pattern, `_%i` will be added automatically.\n\nWhen generating thumbnails, an additional `filenames` event is dispatched with an array of generated filenames as an argument.\n\n```js\nffmpeg('/path/to/video.avi')\n  .on('filenames', function(filenames) {\n    console.log('Will generate ' + filenames.join(', '))\n  })\n  .on('end', function() {\n    console.log('Screenshots taken');\n  })\n  .screenshots({\n    // Will take screens at 20%, 40%, 60% and 80% of the video\n    count: 4,\n    folder: '/path/to/output'\n  });\n\nffmpeg('/path/to/video.avi')\n  .screenshots({\n    timestamps: [30.5, '50%', '01:10.123'],\n    filename: 'thumbnail-at-%s-seconds.png',\n    folder: '/path/to/output',\n    size: '320x240'\n  });\n```\n\n### Controlling the FFmpeg process\n\n#### kill([signal='SIGKILL']): kill any running ffmpeg process\n\nThis method sends `signal` (defaults to 'SIGKILL') to the ffmpeg process.  It only has sense when processing has started.  Sending a signal that terminates the process will result in the `error` event being emitted.\n\n```js\nvar command = ffmpeg('/path/to/video.avi')\n  .videoCodec('libx264')\n  .audioCodec('libmp3lame')\n  .on('start', function() {\n    // Send SIGSTOP to suspend ffmpeg\n    command.kill('SIGSTOP');\n\n    doSomething(function() {\n      // Send SIGCONT to resume ffmpeg\n      command.kill('SIGCONT');\n    });\n  })\n  .save('/path/to/output.mp4');\n\n// Kill ffmpeg after 60 seconds anyway\nsetTimeout(function() {\n  command.on('error', function() {\n    console.log('Ffmpeg has been killed');\n  });\n\n  command.kill();\n}, 60000);\n```\n\n#### renice([niceness=0]): change ffmpeg process priority\n\nThis method alters the niceness (priority) value of any running ffmpeg process (if any) and any process spawned in the future.  The `niceness` parameter may range from -20 (highest priority) to 20 (lowest priority) and defaults to 0 (which is the default process niceness on most *nix systems).\n\n**Note**: this method is ineffective on Windows platforms.\n\n```js\n// Set startup niceness\nvar command = ffmpeg('/path/to/file.avi')\n  .renice(5)\n  .save('/path/to/output.mp4');\n\n// Command takes too long, raise its priority\nsetTimeout(function() {\n  command.renice(-5);\n}, 60000);\n```\n\n\n### Reading video metadata\n\nYou can read metadata from any valid ffmpeg input file with the modules `ffprobe` method.\n\n```js\nffmpeg.ffprobe('/path/to/file.avi', function(err, metadata) {\n    console.dir(metadata);\n});\n```\n\nYou may also call the ffprobe method on an FfmpegCommand to probe one of its input.  You may pass a 0-based input number as a first argument to specify which input to read metadata from, otherwise the method will probe the last added input.\n\n```js\nffmpeg('/path/to/file1.avi')\n  .input('/path/to/file2.avi')\n  .ffprobe(function(err, data) {\n    console.log('file2 metadata:');\n    console.dir(data);\n  });\n\nffmpeg('/path/to/file1.avi')\n  .input('/path/to/file2.avi')\n  .ffprobe(0, function(err, data) {\n    console.log('file1 metadata:');\n    console.dir(data);\n  });\n```\n\n**Warning:** ffprobe may be called with an input stream, but in this case *it will consume data from the stream*, and this data will no longer be available for ffmpeg.  Using both ffprobe and a transcoding command on the same input stream will most likely fail unless the stream is a live stream.  Only do this if you know what you're doing.\n\nThe returned object is the same that is returned by running the following command from your shell (depending on your ffmpeg version you may have to replace `-of` with `-print_format`) :\n\n```sh\n$ ffprobe -of json -show_streams -show_format /path/to/file.avi\n```\n\nIt will contain information about the container (as a `format` key) and an array of streams (as a `stream` key).  The format object and each stream object also contains metadata tags, depending on the format:\n\n```js\n{\n  \"streams\": [\n    {\n      \"index\": 0,\n      \"codec_name\": \"h264\",\n      \"codec_long_name\": \"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10\",\n      \"profile\": \"Constrained Baseline\",\n      \"codec_type\": \"video\",\n      \"codec_time_base\": \"1/48\",\n      \"codec_tag_string\": \"avc1\",\n      \"codec_tag\": \"0x31637661\",\n      \"width\": 320,\n      \"height\": 180,\n      \"has_b_frames\": 0,\n      \"sample_aspect_ratio\": \"1:1\",\n      \"display_aspect_ratio\": \"16:9\",\n      \"pix_fmt\": \"yuv420p\",\n      \"level\": 13,\n      \"r_frame_rate\": \"24/1\",\n      \"avg_frame_rate\": \"24/1\",\n      \"time_base\": \"1/24\",\n      \"start_pts\": 0,\n      \"start_time\": \"0.000000\",\n      \"duration_ts\": 14315,\n      \"duration\": \"596.458333\",\n      \"bit_rate\": \"702655\",\n      \"nb_frames\": \"14315\",\n      \"disposition\": {\n        \"default\": 0,\n        \"dub\": 0,\n        \"original\": 0,\n        \"comment\": 0,\n        \"lyrics\": 0,\n        \"karaoke\": 0,\n        \"forced\": 0,\n        \"hearing_impaired\": 0,\n        \"visual_impaired\": 0,\n        \"clean_effects\": 0,\n        \"attached_pic\": 0\n      },\n      \"tags\": {\n        \"creation_time\": \"1970-01-01 00:00:00\",\n        \"language\": \"und\",\n        \"handler_name\": \"\\fVideoHandler\"\n      }\n    },\n    {\n      \"index\": 1,\n      \"codec_name\": \"aac\",\n      \"codec_long_name\": \"AAC (Advanced Audio Coding)\",\n      \"codec_type\": \"audio\",\n      \"codec_time_base\": \"1/48000\",\n      \"codec_tag_string\": \"mp4a\",\n      \"codec_tag\": \"0x6134706d\",\n      \"sample_fmt\": \"fltp\",\n      \"sample_rate\": \"48000\",\n      \"channels\": 2,\n      \"bits_per_sample\": 0,\n      \"r_frame_rate\": \"0/0\",\n      \"avg_frame_rate\": \"0/0\",\n      \"time_base\": \"1/48000\",\n      \"start_pts\": 0,\n      \"start_time\": \"0.000000\",\n      \"duration_ts\": 28619776,\n      \"duration\": \"596.245333\",\n      \"bit_rate\": \"159997\",\n      \"nb_frames\": \"27949\",\n      \"disposition\": {\n        \"default\": 0,\n        \"dub\": 0,\n        \"original\": 0,\n        \"comment\": 0,\n        \"lyrics\": 0,\n        \"karaoke\": 0,\n        \"forced\": 0,\n        \"hearing_impaired\": 0,\n        \"visual_impaired\": 0,\n        \"clean_effects\": 0,\n        \"attached_pic\": 0\n      },\n      \"tags\": {\n        \"creation_time\": \"1970-01-01 00:00:00\",\n        \"language\": \"und\",\n        \"handler_name\": \"\\fSoundHandler\"\n      }\n    }\n  ],\n  \"format\": {\n    \"filename\": \"http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4\",\n    \"nb_streams\": 2,\n    \"format_name\": \"mov,mp4,m4a,3gp,3g2,mj2\",\n    \"format_long_name\": \"QuickTime / MOV\",\n    \"start_time\": \"0.000000\",\n    \"duration\": \"596.459000\",\n    \"size\": \"64657027\",\n    \"bit_rate\": \"867211\",\n    \"tags\": {\n      \"major_brand\": \"isom\",\n      \"minor_version\": \"512\",\n      \"compatible_brands\": \"mp41\",\n      \"creation_time\": \"1970-01-01 00:00:00\",\n      \"title\": \"Big Buck Bunny\",\n      \"artist\": \"Blender Foundation\",\n      \"composer\": \"Blender Foundation\",\n      \"date\": \"2008\",\n      \"encoder\": \"Lavf52.14.0\"\n    }\n  }\n}\n```\n\n### Querying ffmpeg capabilities\n\nfluent-ffmpeg enables you to query your installed ffmpeg version for supported formats, codecs, encoders and filters.\n\n```js\n\nvar Ffmpeg = require('fluent-ffmpeg');\n\nFfmpeg.getAvailableFormats(function(err, formats) {\n  console.log('Available formats:');\n  console.dir(formats);\n});\n\nFfmpeg.getAvailableCodecs(function(err, codecs) {\n  console.log('Available codecs:');\n  console.dir(codecs);\n});\n\nFfmpeg.getAvailableEncoders(function(err, encoders) {\n  console.log('Available encoders:');\n  console.dir(encoders);\n});\n\nFfmpeg.getAvailableFilters(function(err, filters) {\n  console.log(\"Available filters:\");\n  console.dir(filters);\n});\n\n// Those methods can also be called on commands\nnew Ffmpeg({ source: '/path/to/file.avi' })\n  .getAvailableCodecs(...);\n```\n\nThese methods pass an object to their callback with keys for each available format, codec or filter.\n\nThe returned object for formats looks like:\n\n```js\n{\n  ...\n  mp4: {\n    description: 'MP4 (MPEG-4 Part 14)',\n    canDemux: false,\n    canMux: true\n  },\n  ...\n}\n```\n\n* `canDemux` indicates whether ffmpeg is able to extract streams from (demux) this format\n* `canMux` indicates whether ffmpeg is able to write streams into (mux) this format\n\nThe returned object for codecs looks like:\n\n```js\n{\n  ...\n  mp3: {\n    type: 'audio',\n    description: 'MP3 (MPEG audio layer 3)',\n    canDecode: true,\n    canEncode: true,\n    intraFrameOnly: false,\n    isLossy: true,\n    isLossless: false\n  },\n  ...\n}\n```\n\n* `type` indicates the codec type, either \"audio\", \"video\" or \"subtitle\"\n* `canDecode` tells whether ffmpeg is able to decode streams using this codec\n* `canEncode` tells whether ffmpeg is able to encode streams using this codec\n\nDepending on your ffmpeg version (or if you use avconv instead) other keys may be present, for example:\n\n* `directRendering` tells if codec can render directly in GPU RAM; useless for transcoding purposes\n* `intraFrameOnly` tells if codec can only work with I-frames\n* `isLossy` tells if codec can do lossy encoding/decoding\n* `isLossless` tells if codec can do lossless encoding/decoding\n\nWith some ffmpeg/avcodec versions, the description includes encoder/decoder mentions in the form \"Foo codec (decoders: libdecodefoo) (encoders: libencodefoo)\".  In this case you will want to use those encoders/decoders instead (the codecs object returned by `getAvailableCodecs` will also include them).\n\nThe returned object for encoders looks like:\n\n```js\n{\n  ...\n  libmp3lame: {\n    type: 'audio',\n    description: 'MP3 (MPEG audio layer 3) (codec mp3)',\n    frameMT: false,\n    sliceMT: false,\n    experimental: false,\n    drawHorizBand: false,\n    directRendering: false\n  },\n  ...\n}\n```\n\n* `type` indicates the encoder type, either \"audio\", \"video\" or \"subtitle\"\n* `experimental` indicates whether the encoder is experimental.  When using such a codec, fluent-ffmpeg automatically adds the '-strict experimental' flag.\n\nThe returned object for filters looks like:\n\n```js\n{\n  ...\n  scale: {\n    description: 'Scale the input video to width:height size and/or convert the image format.',\n    input: 'video',\n    multipleInputs: false,\n    output: 'video',\n    multipleOutputs: false\n  },\n  ...\n}\n```\n\n* `input` tells the input type this filter operates on, one of \"audio\", \"video\" or \"none\".  When \"none\", the filter likely generates output from nothing\n* `multipleInputs` tells whether the filter can accept multiple inputs\n* `output` tells the output type this filter generates, one of \"audio\", \"video\" or \"none\".  When \"none\", the filter has no output (sink only)\n* `multipleInputs` tells whether the filter can generate multiple outputs\n\n### Cloning an FfmpegCommand\n\nYou can create clones of an FfmpegCommand instance by calling the `clone()` method.  The clone will be an exact copy of the original at the time it has been called (same inputs, same options, same event handlers, etc.).  This is mainly useful when you want to apply different processing options on the same input.\n\nSetting options, adding inputs or event handlers on a clone will not affect the original command.\n\n```js\n// Create a command to convert source.avi to MP4\nvar command = ffmpeg('/path/to/source.avi')\n  .audioCodec('libfaac')\n  .videoCodec('libx264')\n  .format('mp4');\n\n// Create a clone to save a small resized version\ncommand.clone()\n  .size('320x200')\n  .save('/path/to/output-small.mp4');\n\n// Create a clone to save a medium resized version\ncommand.clone()\n  .size('640x400')\n  .save('/path/to/output-medium.mp4');\n\n// Save a converted version with the original size\ncommand.save('/path/to/output-original-size.mp4');\n```\n\n\n## Contributing\n\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!\n\n### Code contributions\n\nIf you want to add new features or change the API, please submit an issue first to make sure no one else is already working on the same thing and discuss the implementation and API details with maintainers and users by creating an issue.  When everything is settled down, you can submit a pull request.\n\nWhen fixing bugs, you can directly submit a pull request.\n\nMake sure to add tests for your features and bugfixes and update the documentation (see below) before submitting your code!\n\n### Documentation contributions\n\nYou can directly submit pull requests for documentation changes.  Make sure to regenerate the documentation before submitting (see below).\n\n### Updating the documentation\n\nWhen contributing API changes (new methods for example), be sure to update the README file and JSDoc comments in the code.  fluent-ffmpeg comes with a plugin that enables two additional JSDoc tags:\n\n* `@aliases`: document method aliases\n\n```js\n/**\n * ...\n * @method FfmpegCommand#myMethod\n * @aliases myMethodAlias,myOtherMethodAlias\n */\n```\n\n* `@category`: set method category\n\n```js\n/**\n * ...\n * @category Audio\n */\n```\n\nYou can regenerate the JSDoc documentation by running the following command:\n\n```sh\n$ make doc\n```\n\nTo avoid polluting the commit history, make sure to only commit the regenerated JSDoc once and in a specific commit.\n\n### Running tests\n\nTo run unit tests, first make sure you installed npm dependencies (run `npm install`).\n\n```sh\n$ make test\n```\n\nMake sure your ffmpeg installation is up-to-date to prevent strange assertion errors because of missing codecs/bugfixes.\n\n## Main contributors\n\n* [enobrev](http://github.com/enobrev)\n* [njoyard](http://github.com/njoyard)\n* [sadikzzz](http://github.com/sadikzzz)\n* [smremde](http://github.com/smremde)\n* [spruce](http://github.com/spruce)\n* [tagedieb](http://github.com/tagedieb)\n* [tommadema](http://github.com/tommadema)\n* [Weltschmerz](http://github.com/Weltschmerz)\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2011 Stefan Schaermeli \u0026lt;schaermu@gmail.com\u0026gt;\n\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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\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.\n\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Ffluent-ffmpeg%2Fnode-fluent-ffmpeg.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Ffluent-ffmpeg%2Fnode-fluent-ffmpeg?ref=badge_large)","funding_links":[],"categories":["JavaScript","others","Repository","HTML","HarmonyOS","etc","Video","Libraries and Wrappers","Video Encoding, Transcoding \u0026 Packaging Tools"],"sub_categories":["Audio / Video","Windows Manager","Docker Custom Builds","FFmpeg-Based Tools","Torrent"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluent-ffmpeg%2Fnode-fluent-ffmpeg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluent-ffmpeg%2Fnode-fluent-ffmpeg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluent-ffmpeg%2Fnode-fluent-ffmpeg/lists"}