Skip to content

Commit d054c50

Browse files
authored
Merge pull request #1 from ts-ffmpeg/jc-0727--chore-add-ts-types-from-definitely-typed
chore: add ts types from definitely typed
2 parents 601fd5f + 9e19e0d commit d054c50

File tree

11 files changed

+3328
-2002
lines changed

11 files changed

+3328
-2002
lines changed

.npmignore

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
*.md
22
.git*
3-
test/
4-
examples/
3+
doc
4+
examples
5+
test
6+
tools
7+
Makefile
8+
fluent-ffmpeg-tests.ts
9+
node_modules
10+
.github

README.md

Lines changed: 117 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,121 @@
1-
# (Legacy project) Fluent ffmpeg-API for node.js
1+
# Fluent FFmpeg-API with types for node.js
22

33
[![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)
44
[![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)
55

6+
## What will be done with this legacy project
7+
I will merge types from https://www.npmjs.com/package/@types/fluent-ffmpeg into this repo, put types and code ready at one place. \
8+
And later I'm planing to fix [issues from previous repo](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/issues) and [merge PRs](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/pulls).
9+
10+
11+
## Installation
12+
13+
Via npm:
14+
15+
```sh
16+
# this lib starts from v2.2.0, which is the same code with `fluent-ffmpeg@2.1`. I just reduce the useless code in npm lib.
17+
$ npm install @ts-ffmpeg/fluent-ffmpeg
18+
```
19+
20+
21+
### Creating an FFmpeg command
22+
23+
The fluent-ffmpeg module returns a constructor that you can use to instanciate FFmpeg commands.
24+
25+
```ts
26+
// ts
27+
import ffmpeg from '@ts-ffmpeg/fluent-ffmpeg'
28+
const command = ffmpeg();
29+
```
30+
31+
You may pass an input file name or readable stream, a configuration object, or both to the constructor.
32+
33+
```js
34+
const command = ffmpeg('/path/to/file.avi');
35+
const command = ffmpeg(fs.createReadStream('/path/to/file.avi'));
36+
const command = ffmpeg({ option: "value", ... });
37+
const command = ffmpeg('/path/to/file.avi', { option: "value", ... });
38+
```
39+
40+
The following options are available:
41+
* `source`: input file name or readable stream (ignored if an input file is passed to the constructor)
42+
* `timeout`: ffmpeg timeout in seconds (defaults to no timeout)
43+
* `preset` or `presets`: directory to load module presets from (defaults to the `lib/presets` directory in fluent-ffmpeg tree)
44+
* `niceness` or `priority`: ffmpeg niceness value, between -20 and 20; ignored on Windows platforms (defaults to 0)
45+
* `logger`: logger object with `debug()`, `info()`, `warn()` and `error()` methods (defaults to no logging)
46+
* `stdoutLines`: maximum number of lines from ffmpeg stdout/stderr to keep in memory (defaults to 100, use 0 for unlimited storage)
47+
48+
49+
### Specifying inputs
50+
51+
You can add any number of inputs to an Ffmpeg command. An input can be:
52+
* a file name (eg. `/path/to/file.avi`);
53+
* an image pattern (eg. `/path/to/frame%03d.png`);
54+
* 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.
55+
56+
```js
57+
// Note that all fluent-ffmpeg methods are chainable
58+
ffmpeg('/path/to/input1.avi')
59+
.input('/path/to/input2.avi')
60+
.input(fs.createReadStream('/path/to/input3.avi'));
61+
62+
// Passing an input to the constructor is the same as calling .input()
63+
ffmpeg()
64+
.input('/path/to/input1.avi')
65+
.input('/path/to/input2.avi');
66+
67+
// Most methods have several aliases, here you may use addInput or mergeAdd instead
68+
ffmpeg()
69+
.addInput('/path/to/frame%02d.png')
70+
.addInput('/path/to/soundtrack.mp3');
71+
72+
ffmpeg()
73+
.mergeAdd('/path/to/input1.avi')
74+
.mergeAdd('/path/to/input2.avi');
75+
```
76+
77+
### More
78+
This lib is currently written in js for code, and a standalone `index.d.ts` for typing. So you can easily import lib by require or import. For more examples, you can explore the doc below. They are all the same with the lib `fluent-ffmpeg`.
79+
80+
81+
## Credits
82+
### Main contributors from [fluent-ffmpeg/node-fluent-ffmpeg](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg) project
83+
84+
* [enobrev](http://github.com/enobrev)
85+
* [njoyard](http://github.com/njoyard)
86+
* [sadikzzz](http://github.com/sadikzzz)
87+
* [smremde](http://github.com/smremde)
88+
* [spruce](http://github.com/spruce)
89+
* [tagedieb](http://github.com/tagedieb)
90+
* [tommadema](http://github.com/tommadema)
91+
* [Weltschmerz](http://github.com/Weltschmerz)
92+
93+
[and more others](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/graphs/contributors)
94+
95+
96+
### TS types authors from [@types/fluent-ffmpeg](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fluent-ffmpeg)
97+
These definitions were written by KIM Jaesuck a.k.a. gim tcaesvk, DingWeizhe, Mounir Abid, Doyoung Ha, and Prasad Nayak.
98+
99+
100+
## License
101+
102+
(The MIT License)
103+
104+
Copyright (c) 2011 Stefan Schaermeli <schaermu@gmail.com>
105+
106+
Permission 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:
107+
108+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
109+
110+
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.
111+
112+
113+
[![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)
114+
115+
116+
---
117+
# Below are doc from legacy project
118+
6119
## Fluent-ffmpeg is now deprecated
7120

8121
This library is **no longer maintained** and no longer works properly with recent ffmpeg versions. Use it as your own risk, this repository is readonly and does not accept issues or PRs.
@@ -66,14 +179,14 @@ Alternatively, you may set the ffmpeg, ffprobe and flvtool2/flvmeta binary paths
66179
The fluent-ffmpeg module returns a constructor that you can use to instanciate FFmpeg commands.
67180

68181
```js
69-
var FfmpegCommand = require('fluent-ffmpeg');
182+
var FfmpegCommand = require('@ts-ffmpeg/fluent-ffmpeg');
70183
var command = new FfmpegCommand();
71184
```
72185

73186
You can also use the constructor without the `new` operator.
74187

75188
```js
76-
var ffmpeg = require('fluent-ffmpeg');
189+
var ffmpeg = require('@ts-ffmpeg/fluent-ffmpeg');
77190
var command = ffmpeg();
78191
```
79192

@@ -1261,7 +1374,7 @@ fluent-ffmpeg enables you to query your installed ffmpeg version for supported f
12611374

12621375
```js
12631376

1264-
var Ffmpeg = require('fluent-ffmpeg');
1377+
var Ffmpeg = require('@ts-ffmpeg/fluent-ffmpeg');
12651378

12661379
Ffmpeg.getAvailableFormats(function(err, formats) {
12671380
console.log('Available formats:');
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import ffmpeg from '@ts-ffmpeg/fluent-ffmpeg'
2+
3+
async function getVersion () {
4+
return new Promise((resolve, reject) => {
5+
ffmpeg().addOption('-hide_banner').on('error', (error, stdout, stderr) => {
6+
if (error) return reject(error)
7+
8+
if (stderr) console.log('stderr:', stderr)
9+
if (stdout) console.log('stdout:', stdout)
10+
}).on('end', (stdout, stderr) => {
11+
if (stderr) console.log('stderr:', stderr)
12+
if (stdout) console.log('stdout:', stdout)
13+
resolve(stdout || stderr)
14+
}).run()
15+
})
16+
}
17+
18+
await getVersion().catch((err: Error) => {
19+
if (err.message.includes('No output specified')) {
20+
console.log('✅ Pass')
21+
return
22+
}
23+
console.log(err)
24+
})
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "version-validation",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.ts",
6+
"scripts": {
7+
"test": "npx vite-node index.ts"
8+
},
9+
"keywords": [ ],
10+
"author": "Jonham <jonhamchen@gmail.com>",
11+
"license": "MIT",
12+
"packageManager": "pnpm@10.12.3",
13+
"dependencies": {
14+
"@ts-ffmpeg/fluent-ffmpeg": "2.2.2"
15+
},
16+
"devDependencies": {
17+
"vite-node": "^3.2.4"
18+
}
19+
}

0 commit comments

Comments
 (0)