From 48b112b0b3335342723ae50f0f5e730f1324a73b Mon Sep 17 00:00:00 2001 From: fossabot Date: Tue, 14 Nov 2017 00:25:05 -0800 Subject: [PATCH 01/14] Add license scan report and status --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 4cab99cf..b63448bf 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Fluent ffmpeg-API for node.js [![Build Status](https://secure.travis-ci.org/fluent-ffmpeg/node-fluent-ffmpeg.svg?branch=master)](http://travis-ci.org/fluent-ffmpeg/node-fluent-ffmpeg) +[![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) > **Fluent-ffmpeg is looking for new maintainers** > More details [on the wiki](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/wiki/Looking-for-a-new-maintainer) @@ -1487,3 +1488,6 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE 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. + + +[![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) \ No newline at end of file From a9ebbd35cd65f27730e004c1263134c827a8cbfc Mon Sep 17 00:00:00 2001 From: Chris Watson Date: Tue, 9 Jul 2019 16:54:05 +0100 Subject: [PATCH 02/14] Clear process timeout timer when command completes Otherwise the timer needlessly keeps the node process alive. --- lib/processor.js | 4 ++-- test/processor.test.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/processor.js b/lib/processor.js index 5a8e56d7..543037e7 100644 --- a/lib/processor.js +++ b/lib/processor.js @@ -464,9 +464,8 @@ module.exports = function(proto) { } // Setup timeout if requested - var processTimer; if (self.options.timeout) { - processTimer = setTimeout(function() { + self.processTimer = setTimeout(function() { var msg = 'process ran into a timeout (' + self.options.timeout + 's)'; emitEnd(new Error(msg), stdoutRing.get(), stderrRing.get()); @@ -533,6 +532,7 @@ module.exports = function(proto) { }, function endCB(err, stdoutRing, stderrRing) { + clearTimeout(self.processTimer); delete self.ffmpegProc; if (err) { diff --git a/test/processor.test.js b/test/processor.test.js index 7d026682..f5232b03 100644 --- a/test/processor.test.js +++ b/test/processor.test.js @@ -280,6 +280,18 @@ describe('Processor', function() { .saveToFile(testFile); }); + it('should not keep node process running on completion', function(done) { + var script = ` + var ffmpeg = require('.'); + ffmpeg('${this.testfilebig}', { timeout: 60 }) + .addOption('-t', 1) + .addOption('-f', 'null') + .saveToFile('/dev/null'); + `; + + exec(`node -e "${script}"`, { timeout: 1000 }, done); + }); + it('should kill the process with .kill', function(done) { var testFile = path.join(__dirname, 'assets', 'testProcessKill.avi'); this.files.push(testFile); From 9ed900f1958bf7f28e0dd90609735b7a571fcc5b Mon Sep 17 00:00:00 2001 From: Riophae Lee Date: Mon, 5 Aug 2019 13:31:05 +0800 Subject: [PATCH 03/14] remove unused code --- lib/processor.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/processor.js b/lib/processor.js index 543037e7..53113ef1 100644 --- a/lib/processor.js +++ b/lib/processor.js @@ -7,8 +7,6 @@ var fs = require('fs'); var async = require('async'); var utils = require('./utils'); -var nlRegexp = /\r\n|\r|\n/g; - /* *! Processor methods */ From efca49f835e10856320b4a16bd78550f3c973c36 Mon Sep 17 00:00:00 2001 From: Riophae Lee Date: Wed, 7 Aug 2019 03:43:46 +0800 Subject: [PATCH 04/14] small tweak on `run()` method --- lib/processor.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/processor.js b/lib/processor.js index 543037e7..bbaf1257 100644 --- a/lib/processor.js +++ b/lib/processor.js @@ -590,6 +590,8 @@ module.exports = function(proto) { } ); }); + + return this; }; From 04a404a85c9951b2490c90590d1157818b2f4590 Mon Sep 17 00:00:00 2001 From: Aditya Patadia Date: Sat, 17 Aug 2019 16:13:34 +0530 Subject: [PATCH 05/14] updated node version to 12 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 242a2990..c89e0ac3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ matrix: - os: linux env: NODE_VERSION=10 - os: linux - env: NODE_VERSION=11 + env: NODE_VERSION=12 script: - tools/test-travis.sh addons: From d3953b0cfa894a8367fa1f6e85d0fc184826eb0c Mon Sep 17 00:00:00 2001 From: "A.I. Developer" <3321213+8ai@users.noreply.github.com> Date: Tue, 17 Sep 2019 14:39:42 +0300 Subject: [PATCH 06/14] Hide ffprobe console in windows --- lib/ffprobe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ffprobe.js b/lib/ffprobe.js index 3f00fa4c..c0fe20a4 100644 --- a/lib/ffprobe.js +++ b/lib/ffprobe.js @@ -152,7 +152,7 @@ module.exports = function(proto) { // Spawn ffprobe var src = input.isStream ? 'pipe:0' : input.source; - var ffprobe = spawn(path, ['-show_streams', '-show_format'].concat(options, src)); + var ffprobe = spawn(path, ['-show_streams', '-show_format'].concat(options, src), {windowsHide: true}); if (input.isStream) { // Skip errors on stdin. These get thrown when ffprobe is complete and From 99df2910d3275f207da1456ae3479b1e1019906e Mon Sep 17 00:00:00 2001 From: "A.I. Developer" <3321213+8ai@users.noreply.github.com> Date: Tue, 17 Sep 2019 14:43:40 +0300 Subject: [PATCH 07/14] Hide ffmpeg,renice,flvtool console window on windows --- lib/processor.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/processor.js b/lib/processor.js index 543037e7..ccd598d4 100644 --- a/lib/processor.js +++ b/lib/processor.js @@ -439,7 +439,8 @@ module.exports = function(proto) { { captureStdout: !outputStream, niceness: self.options.niceness, - cwd: self.options.cwd + cwd: self.options.cwd, + windowsHide: true }, function processCB(ffmpegProc, stdoutRing, stderrRing) { @@ -557,7 +558,7 @@ module.exports = function(proto) { async.each( flvmeta, function(output, cb) { - spawn(flvtool, ['-U', output.target]) + spawn(flvtool, ['-U', output.target], {windowsHide: true}) .on('error', function(err) { cb(new Error('Error running ' + flvtool + ' on ' + output.target + ': ' + err.message)); }) @@ -618,7 +619,7 @@ module.exports = function(proto) { if (this.ffmpegProc) { var logger = this.logger; var pid = this.ffmpegProc.pid; - var renice = spawn('renice', [niceness, '-p', pid]); + var renice = spawn('renice', [niceness, '-p', pid], {windowsHide: true}); renice.on('error', function(err) { logger.warn('could not renice process ' + pid + ': ' + err.message); From ac38adc02a73c70ec8dafd6c4df5dbcc47290135 Mon Sep 17 00:00:00 2001 From: Jon <9994935+flibustier@users.noreply.github.com> Date: Wed, 18 Sep 2019 15:27:00 +0100 Subject: [PATCH 08/14] Fixing Bug resolve "./lib-cov/fluent-ffmpeg" In order to fix bug referenced in Issues #139, #358 and #573 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 04e594c1..fb4805dd 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports = process.env.FLUENTFFMPEG_COV ? require('./lib-cov/fluent-ffmpeg') : require('./lib/fluent-ffmpeg'); +module.exports = require(`./lib${process.env.FLUENTFFMPEG_COV ? '-cov' : ''}/fluent-ffmpeg`); From 473436b7a8b98404f1a53d6ceb514b3055c82e36 Mon Sep 17 00:00:00 2001 From: "A.I. Developer" <3321213+8ai@users.noreply.github.com> Date: Sun, 29 Sep 2019 20:52:45 +0300 Subject: [PATCH 09/14] Little change for fix pull request test --- lib/processor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/processor.js b/lib/processor.js index ccd598d4..137337a8 100644 --- a/lib/processor.js +++ b/lib/processor.js @@ -441,7 +441,7 @@ module.exports = function(proto) { niceness: self.options.niceness, cwd: self.options.cwd, windowsHide: true - }, + }, function processCB(ffmpegProc, stdoutRing, stderrRing) { self.ffmpegProc = ffmpegProc; From 299b9f522d11f09c552804c4c1794b0a159fbaac Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Fri, 18 Oct 2019 11:32:03 +0900 Subject: [PATCH 10/14] update travis.yml try gem install --- .travis.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 242a2990..e3a120a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ + + before_install: - - sudo add-apt-repository ppa:sauce/ppa -y - - sudo apt-get update -q - - sudo apt-get install flvtool2 -y -matrix: + - gem install flvtool2 + +jobs: include: - os: linux env: NODE_VERSION=8 @@ -10,8 +11,10 @@ matrix: env: NODE_VERSION=10 - os: linux env: NODE_VERSION=11 + script: - tools/test-travis.sh + addons: apt: packages: From 27f79a57ae2cd538bf4efad2a290472d1a8e1cd3 Mon Sep 17 00:00:00 2001 From: lmancel Date: Mon, 10 Feb 2020 16:26:39 +0100 Subject: [PATCH 11/14] ffprobe: added EOF to the list of ignored errors As reported in https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/issues/601, there sometimes are an EOF error on ffprobe process close which prevent from retrieving the metadata even though they have been successfully extracted. --- lib/ffprobe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ffprobe.js b/lib/ffprobe.js index c0fe20a4..d24be85d 100644 --- a/lib/ffprobe.js +++ b/lib/ffprobe.js @@ -158,7 +158,7 @@ module.exports = function(proto) { // Skip errors on stdin. These get thrown when ffprobe is complete and // there seems to be no way hook in and close stdin before it throws. ffprobe.stdin.on('error', function(err) { - if (['ECONNRESET', 'EPIPE'].indexOf(err.code) >= 0) { return; } + if (['ECONNRESET', 'EPIPE', 'EOF'].indexOf(err.code) >= 0) { return; } handleCallback(err); }); From 777fde7f618ecbbce9890d8c2ef3dbd50ff9c413 Mon Sep 17 00:00:00 2001 From: Artur Aralin Date: Fri, 1 May 2020 13:59:13 +0300 Subject: [PATCH 12/14] add example any-to-mp4-steam.js --- examples/any-to-mp4-steam.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 examples/any-to-mp4-steam.js diff --git a/examples/any-to-mp4-steam.js b/examples/any-to-mp4-steam.js new file mode 100644 index 00000000..c78f93ca --- /dev/null +++ b/examples/any-to-mp4-steam.js @@ -0,0 +1,16 @@ +// The solution based on adding -movflags for mp4 output +// For more movflags details check ffmpeg docs +// https://ffmpeg.org/ffmpeg-formats.html#toc-Options-9 + +var fs = require('fs'); +var path = require('path'); +var ffmpeg = require('../index'); + +var pathToSourceFile = path.resolve(__dirname, '../test/assets/testvideo-169.avi'); +var readStream = fs.createReadStream(pathToSourceFile); +var writeStream = fs.createWriteStream('./output.mp4'); + +ffmpeg(readStream) + .addOutputOptions('-movflags +frag_keyframe+separate_moof+omit_tfhd_offset+empty_moov') + .format('mp4') + .pipe(writeStream); From 183a12d8faee3af37f46070f3cc0fbb266de1040 Mon Sep 17 00:00:00 2001 From: Andrei Popa Date: Tue, 13 Apr 2021 14:12:14 +0300 Subject: [PATCH 13/14] Changed version and scope --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f889d9be..f3d2c6ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "fluent-ffmpeg", - "version": "2.1.2", + "name": "@ownzones/fluent-ffmpeg", + "version": "2.2.0", "description": "A fluent API to FFMPEG (http://www.ffmpeg.org)", "keywords": [ "ffmpeg" From 27a387d2d7b1435a6eb5189fddf1d3f3235e6632 Mon Sep 17 00:00:00 2001 From: Andrei Popa Date: Tue, 13 Apr 2021 16:37:29 +0300 Subject: [PATCH 14/14] Added typescript definitions --- index.d.ts | 415 ++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +- tsconfig.json | 22 +++ 3 files changed, 440 insertions(+), 1 deletion(-) create mode 100644 index.d.ts create mode 100644 tsconfig.json diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 00000000..31edde8d --- /dev/null +++ b/index.d.ts @@ -0,0 +1,415 @@ +// Type definitions for node-fluent-ffmpeg 2.1 +// Project: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg +// Definitions by: KIM Jaesuck a.k.a. gim tcaesvk +// DingWeizhe +// Mounir Abid +// Doyoung Ha +// Prasad Nayak +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as events from "events"; +import * as stream from "stream"; + +declare namespace Ffmpeg { + interface FfmpegCommandLogger { + error(...data: any[]): void; + warn(...data: any[]): void; + info(...data: any[]): void; + debug(...data: any[]): void; + } + + interface FfmpegCommandOptions { + logger?: FfmpegCommandLogger; + niceness?: number; + priority?: number; + presets?: string; + preset?: string; + stdoutLines?: number; + timeout?: number; + source?: string | stream.Readable; + cwd?: string; + } + + interface FilterSpecification { + filter: string; + inputs?: string | string[]; + outputs?: string | string[]; + options?: any | string | any[]; + } + + type GetPreset = (command: FfmpegCommand) => string; + + interface Filter { + description: string; + input: string; + multipleInputs: boolean; + output: string; + multipleOutputs: boolean; + } + interface Filters { + [key: string]: Filter; + } + type FiltersCallback = (err: Error, filters: Filters) => void; + + interface Codec { + type: string; + description: string; + canDecode: boolean; + canEncode: boolean; + drawHorizBand?: boolean; + directRendering?: boolean; + weirdFrameTruncation?: boolean; + intraFrameOnly?: boolean; + isLossy?: boolean; + isLossless?: boolean; + } + interface Codecs { + [key: string]: Codec; + } + type CodecsCallback = (err: Error, codecs: Codecs) => void; + + interface Encoder { + type: string; + description: string; + frameMT: boolean; + sliceMT: boolean; + experimental: boolean; + drawHorizBand: boolean; + directRendering: boolean; + } + interface Encoders { + [key: string]: Encoder; + } + type EncodersCallback = (err: Error, encoders: Encoders) => void; + + interface Format { + description: string; + canDemux: boolean; + canMux: boolean; + } + interface Formats { + [key: string]: Format; + } + type FormatsCallback = (err: Error, formats: Formats) => void; + + interface FfprobeData { + streams: FfprobeStream[]; + format: FfprobeFormat; + chapters: any[]; + } + + interface FfprobeStream { + [key: string]: any; + index: number; + codec_name?: string; + codec_long_name?: string; + profile?: number; + codec_type?: string; + codec_time_base?: string; + codec_tag_string?: string; + codec_tag?: string; + width?: number; + height?: number; + coded_width?: number; + coded_height?: number; + has_b_frames?: number; + sample_aspect_ratio?: string; + display_aspect_ratio?: string; + pix_fmt?: string; + level?: string; + color_range?: string; + color_space?: string; + color_transfer?: string; + color_primaries?: string; + chroma_location?: string; + field_order?: string; + timecode?: string; + refs?: number; + id?: string; + r_frame_rate?: string; + avg_frame_rate?: string; + time_base?: string; + start_pts?: number; + start_time?: number; + duration_ts?: string; + duration?: string; + bit_rate?: string; + max_bit_rate?: string; + bits_per_raw_sample?: string; + nb_frames?: string; + nb_read_frames?: string; + nb_read_packets?: string; + sample_fmt?: string; + sample_rate?: number; + channels?: number; + channel_layout?: string; + bits_per_sample?: number; + disposition?: FfprobeStreamDisposition; + rotation?: string | number; + } + + interface FfprobeStreamDisposition { + [key: string]: any; + default?: number; + dub?: number; + original?: number; + comment?: number; + lyrics?: number; + karaoke?: number; + forced?: number; + hearing_impaired?: number; + visual_impaired?: number; + clean_effects?: number; + attached_pic?: number; + timed_thumbnails?: number; + } + + interface FfprobeFormat { + [key: string]: any; + filename?: string; + nb_streams?: number; + nb_programs?: number; + format_name?: string; + format_long_name?: string; + start_time?: number; + duration?: number; + size?: number; + bit_rate?: number; + probe_score?: number; + tags?: any[]; + } + + interface ScreenshotsConfig { + count?: number; + folder?: string; + filename?: string; + timemarks?: number[] | string[]; + timestamps?: number[] | string[]; + fastSeek?: boolean; + size?: string; + } + + interface AudioVideoFilter { + filter: string; + options: string | string[] | {}; + } + + // static methods + function setFfmpegPath(path: string): FfmpegCommand; + function setFfprobePath(path: string): FfmpegCommand; + function setFlvtoolPath(path: string): FfmpegCommand; + function availableFilters(callback: FiltersCallback): void; + function getAvailableFilters(callback: FiltersCallback): void; + function availableCodecs(callback: CodecsCallback): void; + function getAvailableCodecs(callback: CodecsCallback): void; + function availableEncoders(callback: EncodersCallback): void; + function getAvailableEncoders(callback: EncodersCallback): void; + function availableFormats(callback: FormatsCallback): void; + function getAvailableFormats(callback: FormatsCallback): void; + + class FfmpegCommand extends events.EventEmitter { + constructor(options?: FfmpegCommandOptions); + constructor(input?: string | stream.Readable, options?: FfmpegCommandOptions); + + // options/inputs + mergeAdd(source: string | stream.Readable): FfmpegCommand; + addInput(source: string | stream.Readable): FfmpegCommand; + input(source: string | stream.Readable): FfmpegCommand; + withInputFormat(format: string): FfmpegCommand; + inputFormat(format: string): FfmpegCommand; + fromFormat(format: string): FfmpegCommand; + withInputFps(fps: number): FfmpegCommand; + withInputFPS(fps: number): FfmpegCommand; + withFpsInput(fps: number): FfmpegCommand; + withFPSInput(fps: number): FfmpegCommand; + inputFPS(fps: number): FfmpegCommand; + inputFps(fps: number): FfmpegCommand; + fpsInput(fps: number): FfmpegCommand; + FPSInput(fps: number): FfmpegCommand; + nativeFramerate(): FfmpegCommand; + withNativeFramerate(): FfmpegCommand; + native(): FfmpegCommand; + setStartTime(seek: string | number): FfmpegCommand; + seekInput(seek: string | number): FfmpegCommand; + loop(duration?: string | number): FfmpegCommand; + + // options/audio + withNoAudio(): FfmpegCommand; + noAudio(): FfmpegCommand; + withAudioCodec(codec: string): FfmpegCommand; + audioCodec(codec: string): FfmpegCommand; + withAudioBitrate(bitrate: string | number): FfmpegCommand; + audioBitrate(bitrate: string | number): FfmpegCommand; + withAudioChannels(channels: number): FfmpegCommand; + audioChannels(channels: number): FfmpegCommand; + withAudioFrequency(freq: number): FfmpegCommand; + audioFrequency(freq: number): FfmpegCommand; + withAudioQuality(quality: number): FfmpegCommand; + audioQuality(quality: number): FfmpegCommand; + withAudioFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + withAudioFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + audioFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + audioFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + + // options/video; + withNoVideo(): FfmpegCommand; + noVideo(): FfmpegCommand; + withVideoCodec(codec: string): FfmpegCommand; + videoCodec(codec: string): FfmpegCommand; + withVideoBitrate(bitrate: string | number, constant?: boolean): FfmpegCommand; + videoBitrate(bitrate: string | number, constant?: boolean): FfmpegCommand; + withVideoFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + withVideoFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + videoFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + videoFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + withOutputFps(fps: number): FfmpegCommand; + withOutputFPS(fps: number): FfmpegCommand; + withFpsOutput(fps: number): FfmpegCommand; + withFPSOutput(fps: number): FfmpegCommand; + withFps(fps: number): FfmpegCommand; + withFPS(fps: number): FfmpegCommand; + outputFPS(fps: number): FfmpegCommand; + outputFps(fps: number): FfmpegCommand; + fpsOutput(fps: number): FfmpegCommand; + FPSOutput(fps: number): FfmpegCommand; + fps(fps: number): FfmpegCommand; + FPS(fps: number): FfmpegCommand; + takeFrames(frames: number): FfmpegCommand; + withFrames(frames: number): FfmpegCommand; + frames(frames: number): FfmpegCommand; + + // options/videosize + keepPixelAspect(): FfmpegCommand; + keepDisplayAspect(): FfmpegCommand; + keepDisplayAspectRatio(): FfmpegCommand; + keepDAR(): FfmpegCommand; + withSize(size: string): FfmpegCommand; + setSize(size: string): FfmpegCommand; + size(size: string): FfmpegCommand; + withAspect(aspect: string | number): FfmpegCommand; + withAspectRatio(aspect: string | number): FfmpegCommand; + setAspect(aspect: string | number): FfmpegCommand; + setAspectRatio(aspect: string | number): FfmpegCommand; + aspect(aspect: string | number): FfmpegCommand; + aspectRatio(aspect: string | number): FfmpegCommand; + applyAutopadding(pad?: boolean, color?: string): FfmpegCommand; + applyAutoPadding(pad?: boolean, color?: string): FfmpegCommand; + applyAutopad(pad?: boolean, color?: string): FfmpegCommand; + applyAutoPad(pad?: boolean, color?: string): FfmpegCommand; + withAutopadding(pad?: boolean, color?: string): FfmpegCommand; + withAutoPadding(pad?: boolean, color?: string): FfmpegCommand; + withAutopad(pad?: boolean, color?: string): FfmpegCommand; + withAutoPad(pad?: boolean, color?: string): FfmpegCommand; + autoPad(pad?: boolean, color?: string): FfmpegCommand; + autopad(pad?: boolean, color?: string): FfmpegCommand; + + // options/output + addOutput(target: string | stream.Writable, pipeopts?: { end?: boolean }): FfmpegCommand; + output(target: string | stream.Writable, pipeopts?: { end?: boolean }): FfmpegCommand; + seekOutput(seek: string | number): FfmpegCommand; + seek(seek: string | number): FfmpegCommand; + withDuration(duration: string | number): FfmpegCommand; + setDuration(duration: string | number): FfmpegCommand; + duration(duration: string | number): FfmpegCommand; + toFormat(format: string): FfmpegCommand; + withOutputFormat(format: string): FfmpegCommand; + outputFormat(format: string): FfmpegCommand; + format(format: string): FfmpegCommand; + map(spec: string): FfmpegCommand; + updateFlvMetadata(): FfmpegCommand; + flvmeta(): FfmpegCommand; + preset(format: string): FfmpegCommand; + + // options/custom + addInputOption(options: string[]): FfmpegCommand; + addInputOption(...options: string[]): FfmpegCommand; + addInputOptions(options: string[]): FfmpegCommand; + addInputOptions(...options: string[]): FfmpegCommand; + withInputOption(options: string[]): FfmpegCommand; + withInputOption(...options: string[]): FfmpegCommand; + withInputOptions(options: string[]): FfmpegCommand; + withInputOptions(...options: string[]): FfmpegCommand; + inputOption(options: string[]): FfmpegCommand; + inputOption(...options: string[]): FfmpegCommand; + inputOptions(options: string[]): FfmpegCommand; + inputOptions(...options: string[]): FfmpegCommand; + addOutputOption(options: string[]): FfmpegCommand; + addOutputOption(...options: string[]): FfmpegCommand; + addOutputOptions(options: string[]): FfmpegCommand; + addOutputOptions(...options: string[]): FfmpegCommand; + addOption(options: string[]): FfmpegCommand; + addOption(...options: string[]): FfmpegCommand; + addOptions(options: string[]): FfmpegCommand; + addOptions(...options: string[]): FfmpegCommand; + withOutputOption(options: string[]): FfmpegCommand; + withOutputOption(...options: string[]): FfmpegCommand; + withOutputOptions(options: string[]): FfmpegCommand; + withOutputOptions(...options: string[]): FfmpegCommand; + withOption(options: string[]): FfmpegCommand; + withOption(...options: string[]): FfmpegCommand; + withOptions(options: string[]): FfmpegCommand; + withOptions(...options: string[]): FfmpegCommand; + outputOption(options: string[]): FfmpegCommand; + outputOption(...options: string[]): FfmpegCommand; + outputOptions(options: string[]): FfmpegCommand; + outputOptions(...options: string[]): FfmpegCommand; + filterGraph(spec: string | FilterSpecification | Array, map?: string[] | string): FfmpegCommand; + complexFilter(spec: string | FilterSpecification | Array, map?: string[] | string): FfmpegCommand; + + // options/misc + usingPreset(proset: string | GetPreset): FfmpegCommand; + pnreset(proset: string | GetPreset): FfmpegCommand; + + // processor + renice(niceness: number): FfmpegCommand; + kill(signal: string): FfmpegCommand; + _getArguments(): string[]; + + // capabilities + setFfmpegPath(path: string): FfmpegCommand; + setFfprobePath(path: string): FfmpegCommand; + setFlvtoolPath(path: string): FfmpegCommand; + availableFilters(callback: FiltersCallback): void; + getAvailableFilters(callback: FiltersCallback): void; + availableCodecs(callback: CodecsCallback): void; + getAvailableCodecs(callback: CodecsCallback): void; + availableEncoders(callback: EncodersCallback): void; + getAvailableEncoders(callback: EncodersCallback): void; + availableFormats(callback: FormatsCallback): void; + getAvailableFormats(callback: FormatsCallback): void; + + // ffprobe + ffprobe(callback: (err: any, data: FfprobeData) => void): void; + ffprobe(index: number, callback: (err: any, data: FfprobeData) => void): void; + ffprobe(options: string[], callback: (err: any, data: FfprobeData) => void): void; // tslint:disable-line unified-signatures + ffprobe(index: number, options: string[], callback: (err: any, data: FfprobeData) => void): void; + + // recipes + saveToFile(output: string): FfmpegCommand; + save(output: string): FfmpegCommand; + writeToStream(stream: stream.Writable, options?: { end?: boolean }): stream.Writable; + pipe(stream?: stream.Writable, options?: { end?: boolean }): stream.Writable|stream.PassThrough; + stream(stream: stream.Writable, options?: { end?: boolean }): stream.Writable; + takeScreenshots(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand; + thumbnail(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand; + thumbnails(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand; + screenshot(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand; + screenshots(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand; + mergeToFile(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand; + concatenate(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand; + concat(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand; + clone(): FfmpegCommand; + run(): void; + } + + function ffprobe(file: string, callback: (err: any, data: FfprobeData) => void): void; + function ffprobe(file: string, index: number, callback: (err: any, data: FfprobeData) => void): void; + function ffprobe(file: string, options: string[], callback: (err: any, data: FfprobeData) => void): void; // tslint:disable-line unified-signatures + function ffprobe(file: string, index: number, options: string[], callback: (err: any, data: FfprobeData) => void): void; +} +declare function Ffmpeg(options?: Ffmpeg.FfmpegCommandOptions): Ffmpeg.FfmpegCommand; +declare function Ffmpeg(input?: string | stream.Readable, options?: Ffmpeg.FfmpegCommandOptions): Ffmpeg.FfmpegCommand; + +export = Ffmpeg; diff --git a/package.json b/package.json index f3d2c6ab..d3ba1698 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ownzones/fluent-ffmpeg", - "version": "2.2.0", + "version": "2.2.1", "description": "A fluent API to FFMPEG (http://www.ffmpeg.org)", "keywords": [ "ffmpeg" @@ -19,6 +19,8 @@ }, "repository": "git://github.com/fluent-ffmpeg/node-fluent-ffmpeg.git", "devDependencies": { + "@types/node": "12.7.5", + "typescript": "4.2.4", "mocha": "latest", "should": "latest", "jsdoc": "latest" diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..41c77085 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "./", + "typeRoots": [ + "./" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + ] +}