bare-ffmpeg 1.0.0-15 → 1.0.0-16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.cc +755 -17
- package/index.d.ts +46 -0
- package/index.js +5 -3
- package/lib/audio-fifo.d.ts +20 -0
- package/lib/channel-layout.d.ts +9 -0
- package/lib/channel-layout.js +11 -0
- package/lib/codec-context.d.ts +34 -0
- package/lib/codec-context.js +43 -1
- package/lib/codec-parameters.d.ts +20 -0
- package/lib/codec-parameters.js +38 -0
- package/lib/codec.d.ts +20 -0
- package/lib/codec.js +14 -0
- package/lib/constants.d.ts +74 -0
- package/lib/constants.js +49 -3
- package/lib/decoder.d.ts +7 -0
- package/lib/dictionary.d.ts +11 -0
- package/lib/dictionary.js +2 -0
- package/lib/encoder.d.ts +7 -0
- package/lib/format-context.d.ts +43 -0
- package/lib/format-context.js +28 -5
- package/lib/frame.d.ts +23 -0
- package/lib/frame.js +42 -0
- package/lib/image.d.ts +30 -0
- package/lib/input-format.d.ts +5 -0
- package/lib/input-format.js +4 -0
- package/lib/io-context.d.ts +10 -0
- package/lib/io-context.js +24 -6
- package/lib/log.js +16 -0
- package/lib/output-format.d.ts +5 -0
- package/lib/output-format.js +4 -0
- package/lib/packet.d.ts +16 -0
- package/lib/packet.js +77 -0
- package/lib/rational.d.ts +8 -0
- package/lib/rational.js +27 -1
- package/lib/resampler.d.ts +26 -0
- package/lib/resampler.js +2 -2
- package/lib/samples.d.ts +16 -0
- package/lib/scaler.d.ts +26 -0
- package/lib/scaler.js +2 -2
- package/lib/stream.d.ts +18 -0
- package/lib/stream.js +38 -5
- package/package.json +17 -3
- package/prebuilds/android-arm/bare-ffmpeg.bare +0 -0
- package/prebuilds/android-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/android-ia32/bare-ffmpeg.bare +0 -0
- package/prebuilds/android-x64/bare-ffmpeg.bare +0 -0
- package/prebuilds/darwin-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/darwin-x64/bare-ffmpeg.bare +0 -0
- package/prebuilds/ios-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-ffmpeg.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-ffmpeg.bare +0 -0
- package/prebuilds/linux-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/linux-x64/bare-ffmpeg.bare +0 -0
- package/prebuilds/win32-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/win32-x64/bare-ffmpeg.bare +0 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import FFmpegAudioFIFO from './lib/audio-fifo'
|
|
2
|
+
import FFmpegChannelLayout from './lib/channel-layout'
|
|
3
|
+
import FFmpegCodec from './lib/codec'
|
|
4
|
+
import FFmpegCodecContext from './lib/codec-context'
|
|
5
|
+
import FFmpegCodecParameters from './lib/codec-parameters'
|
|
6
|
+
import FFmpegDecoder from './lib/decoder'
|
|
7
|
+
import FFmpegDictionary from './lib/dictionary'
|
|
8
|
+
import FFmpegEncoder from './lib/encoder'
|
|
9
|
+
import { InputFormatContext, OutputFormatContext } from './lib/format-context'
|
|
10
|
+
import FFmpegFrame from './lib/frame'
|
|
11
|
+
import FFmpegIOContext from './lib/io-context'
|
|
12
|
+
import FFmpegImage from './lib/image'
|
|
13
|
+
import FFmpegInputFormat from './lib/input-format'
|
|
14
|
+
import FFmpegOutputFormat from './lib/output-format'
|
|
15
|
+
import FFmpegPacket from './lib/packet'
|
|
16
|
+
import FFmpegRational from './lib/rational'
|
|
17
|
+
import FFmpegResampler from './lib/resampler'
|
|
18
|
+
import FFmpegSamples from './lib/samples'
|
|
19
|
+
import FFmpegScaler from './lib/scaler'
|
|
20
|
+
import FFmpegStream from './lib/stream'
|
|
21
|
+
import constants from './lib/constants'
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
FFmpegAudioFIFO as AudioFIFO,
|
|
25
|
+
FFmpegChannelLayout as ChannelLayout,
|
|
26
|
+
FFmpegCodec as Codec,
|
|
27
|
+
FFmpegCodecContext as CodecContext,
|
|
28
|
+
FFmpegCodecParameters as CodecParameters,
|
|
29
|
+
FFmpegDecoder as Decoder,
|
|
30
|
+
FFmpegDictionary as Dictionary,
|
|
31
|
+
FFmpegEncoder as Encoder,
|
|
32
|
+
FFmpegFrame as Frame,
|
|
33
|
+
FFmpegIOContext as IOContext,
|
|
34
|
+
FFmpegImage as Image,
|
|
35
|
+
FFmpegInputFormat as InputFormat,
|
|
36
|
+
FFmpegOutputFormat as OutputFormat,
|
|
37
|
+
FFmpegPacket as Packet,
|
|
38
|
+
FFmpegRational as Rational,
|
|
39
|
+
FFmpegResampler as Resampler,
|
|
40
|
+
FFmpegSamples as Samples,
|
|
41
|
+
FFmpegScaler as Scaler,
|
|
42
|
+
FFmpegStream as Stream,
|
|
43
|
+
InputFormatContext,
|
|
44
|
+
OutputFormatContext,
|
|
45
|
+
constants
|
|
46
|
+
}
|
package/index.js
CHANGED
|
@@ -11,16 +11,17 @@ const {
|
|
|
11
11
|
OutputFormatContext
|
|
12
12
|
} = require('./lib/format-context')
|
|
13
13
|
const Frame = require('./lib/frame')
|
|
14
|
-
const Image = require('./lib/image')
|
|
15
14
|
const IOContext = require('./lib/io-context')
|
|
15
|
+
const Image = require('./lib/image')
|
|
16
16
|
const InputFormat = require('./lib/input-format')
|
|
17
17
|
const OutputFormat = require('./lib/output-format')
|
|
18
18
|
const Packet = require('./lib/packet')
|
|
19
|
+
const Rational = require('./lib/rational')
|
|
20
|
+
const Resampler = require('./lib/resampler')
|
|
19
21
|
const Samples = require('./lib/samples')
|
|
20
22
|
const Scaler = require('./lib/scaler')
|
|
21
23
|
const Stream = require('./lib/stream')
|
|
22
|
-
const
|
|
23
|
-
const Resampler = require('./lib/resampler')
|
|
24
|
+
const log = require('./lib/log')
|
|
24
25
|
|
|
25
26
|
exports.AudioFIFO = AudioFIFO
|
|
26
27
|
exports.ChannelLayout = ChannelLayout
|
|
@@ -43,5 +44,6 @@ exports.Scaler = Scaler
|
|
|
43
44
|
exports.Stream = Stream
|
|
44
45
|
exports.Rational = Rational
|
|
45
46
|
exports.Resampler = Resampler
|
|
47
|
+
exports.log = log
|
|
46
48
|
|
|
47
49
|
exports.constants = require('./lib/constants')
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import FFmpegFrame from './frame'
|
|
2
|
+
|
|
3
|
+
declare class FFmpegAudioFIFO {
|
|
4
|
+
readonly size: number
|
|
5
|
+
readonly space: number
|
|
6
|
+
|
|
7
|
+
constructor(sampleFormat: number, channels: number, nbSamples: number)
|
|
8
|
+
|
|
9
|
+
write(frame: FFmpegFrame): number
|
|
10
|
+
read(frame: FFmpegFrame, nbSamples: number): number
|
|
11
|
+
peek(frame: FFmpegFrame, nbSamples: number): number
|
|
12
|
+
drain(nbSamples: number): number
|
|
13
|
+
|
|
14
|
+
reset(): void
|
|
15
|
+
|
|
16
|
+
destroy(): void
|
|
17
|
+
[Symbol.dispose](): void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export = FFmpegAudioFIFO
|
package/lib/channel-layout.js
CHANGED
|
@@ -10,6 +10,10 @@ module.exports = class FFmpegChannelLayout {
|
|
|
10
10
|
return binding.getChannelLayoutNbChannels(this._handle)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
get mask() {
|
|
14
|
+
return binding.getChannelLayoutMask(this._handle)
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
static from(value) {
|
|
14
18
|
if (typeof value === 'string') value = constants.toChannelLayout(value)
|
|
15
19
|
|
|
@@ -21,4 +25,11 @@ module.exports = class FFmpegChannelLayout {
|
|
|
21
25
|
|
|
22
26
|
return new this(value)
|
|
23
27
|
}
|
|
28
|
+
|
|
29
|
+
[Symbol.for('bare.inspect')]() {
|
|
30
|
+
return {
|
|
31
|
+
__proto__: { constructor: FFmpegChannelLayout },
|
|
32
|
+
nbChannels: this.nbChannels
|
|
33
|
+
}
|
|
34
|
+
}
|
|
24
35
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import FFmpegChannelLayout from './channel-layout'
|
|
2
|
+
import FFmpegDictionary from './dictionary'
|
|
3
|
+
import FFmpegEncoder from './encoder'
|
|
4
|
+
import FFmpegFrame from './frame'
|
|
5
|
+
import FFmpegPacket from './packet'
|
|
6
|
+
import FFmpegRational from './rational'
|
|
7
|
+
|
|
8
|
+
declare class FFmpegCodecContext {
|
|
9
|
+
pixelFormat: number
|
|
10
|
+
width: number
|
|
11
|
+
height: number
|
|
12
|
+
sampleFormat: number
|
|
13
|
+
sampleRate: number
|
|
14
|
+
timeBase: FFmpegRational
|
|
15
|
+
gopSize: number
|
|
16
|
+
|
|
17
|
+
get channelLayout(): FFmpegChannelLayout
|
|
18
|
+
set channelLayout(value: FFmpegChannelLayout | string | number)
|
|
19
|
+
|
|
20
|
+
constructor(codec: FFmpegEncoder)
|
|
21
|
+
|
|
22
|
+
open(options?: FFmpegDictionary): this
|
|
23
|
+
|
|
24
|
+
sendPacket(packet: FFmpegPacket): boolean
|
|
25
|
+
receivePacket(packet: FFmpegPacket): boolean
|
|
26
|
+
|
|
27
|
+
sendFrame(frame: FFmpegFrame): boolean
|
|
28
|
+
receiveFrame(frame: FFmpegFrame): boolean
|
|
29
|
+
|
|
30
|
+
destroy(): void
|
|
31
|
+
[Symbol.dispose](): void
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export = FFmpegCodecContext
|
package/lib/codec-context.js
CHANGED
|
@@ -67,6 +67,19 @@ module.exports = class FFmpegCodecContext {
|
|
|
67
67
|
)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
get frameRate() {
|
|
71
|
+
const view = new Int32Array(binding.getCodecContextFramerate(this._handle))
|
|
72
|
+
return new Rational(view[0], view[1])
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
set frameRate(value) {
|
|
76
|
+
binding.setCodecContextFramerate(
|
|
77
|
+
this._handle,
|
|
78
|
+
value.numerator,
|
|
79
|
+
value.denominator
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
70
83
|
get channelLayout() {
|
|
71
84
|
return new ChannelLayout(binding.getCodecContextChannelLayout(this._handle))
|
|
72
85
|
}
|
|
@@ -86,6 +99,14 @@ module.exports = class FFmpegCodecContext {
|
|
|
86
99
|
binding.setCodecContextGOPSize(this._handle, value)
|
|
87
100
|
}
|
|
88
101
|
|
|
102
|
+
get flags() {
|
|
103
|
+
return binding.getCodecContextFlags(this._handle)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
set flags(value) {
|
|
107
|
+
binding.setCodecContextFlags(this._handle, value)
|
|
108
|
+
}
|
|
109
|
+
|
|
89
110
|
open(options) {
|
|
90
111
|
if (this._opened) return
|
|
91
112
|
this._opened = true
|
|
@@ -106,7 +127,11 @@ module.exports = class FFmpegCodecContext {
|
|
|
106
127
|
}
|
|
107
128
|
|
|
108
129
|
sendFrame(frame) {
|
|
109
|
-
|
|
130
|
+
let frameHandle = undefined
|
|
131
|
+
|
|
132
|
+
if (frame) frameHandle = frame._handle
|
|
133
|
+
|
|
134
|
+
return binding.sendCodecContextFrame(this._handle, frameHandle)
|
|
110
135
|
}
|
|
111
136
|
|
|
112
137
|
receiveFrame(frame) {
|
|
@@ -116,4 +141,21 @@ module.exports = class FFmpegCodecContext {
|
|
|
116
141
|
[Symbol.dispose]() {
|
|
117
142
|
this.destroy()
|
|
118
143
|
}
|
|
144
|
+
|
|
145
|
+
[Symbol.for('bare.inspect')]() {
|
|
146
|
+
return {
|
|
147
|
+
__proto__: { constructor: FFmpegCodecContext },
|
|
148
|
+
_codec: this._codec,
|
|
149
|
+
_opened: this._opened,
|
|
150
|
+
flags: this.flags,
|
|
151
|
+
pixelFormat: this.pixelFormat,
|
|
152
|
+
width: this.width,
|
|
153
|
+
height: this.height,
|
|
154
|
+
sampleFormat: this.sampleFormat,
|
|
155
|
+
sampleRate: this.sampleRate,
|
|
156
|
+
timeBase: this.timeBase,
|
|
157
|
+
channelLayout: this.channelLayout,
|
|
158
|
+
gopSize: this.gopSize
|
|
159
|
+
}
|
|
160
|
+
}
|
|
119
161
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import FFmpegChannelLayout from './channel-layout'
|
|
2
|
+
import FFmpegCodecContext from './codec-context'
|
|
3
|
+
|
|
4
|
+
declare class FFmpegCodecParameters {
|
|
5
|
+
readonly bitRate: number
|
|
6
|
+
readonly bitsPerCodedSample: number
|
|
7
|
+
readonly bitsPerRawSample: number
|
|
8
|
+
readonly format: number
|
|
9
|
+
readonly sampleRate: number
|
|
10
|
+
readonly nbChannels: number
|
|
11
|
+
readonly codecType: number
|
|
12
|
+
readonly channelLayout: FFmpegChannelLayout
|
|
13
|
+
|
|
14
|
+
constructor(handle: ArrayBuffer)
|
|
15
|
+
|
|
16
|
+
fromContext(context: FFmpegCodecContext): void
|
|
17
|
+
toContext(context: FFmpegCodecContext): void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export = FFmpegCodecParameters
|
package/lib/codec-parameters.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const binding = require('../binding')
|
|
2
2
|
const ChannelLayout = require('./channel-layout')
|
|
3
|
+
const Rational = require('./rational')
|
|
3
4
|
|
|
4
5
|
module.exports = class FFmpegCodecParameters {
|
|
5
6
|
constructor(handle) {
|
|
@@ -26,6 +27,13 @@ module.exports = class FFmpegCodecParameters {
|
|
|
26
27
|
return binding.getCodecParametersSampleRate(this._handle)
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
get frameRate() {
|
|
31
|
+
const view = new Int32Array(
|
|
32
|
+
binding.getCodecParametersFramerate(this._handle)
|
|
33
|
+
)
|
|
34
|
+
return new Rational(view[0], view[1])
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
get nbChannels() {
|
|
30
38
|
return binding.getCodecParametersNbChannels(this._handle)
|
|
31
39
|
}
|
|
@@ -34,12 +42,24 @@ module.exports = class FFmpegCodecParameters {
|
|
|
34
42
|
return binding.getCodecParametersCodecType(this._handle)
|
|
35
43
|
}
|
|
36
44
|
|
|
45
|
+
get codecId() {
|
|
46
|
+
return binding.getCodecParametersCodecId(this._handle)
|
|
47
|
+
}
|
|
48
|
+
|
|
37
49
|
get channelLayout() {
|
|
38
50
|
return new ChannelLayout(
|
|
39
51
|
binding.getCodecParametersChannelLayout(this._handle)
|
|
40
52
|
)
|
|
41
53
|
}
|
|
42
54
|
|
|
55
|
+
get width() {
|
|
56
|
+
return binding.getCodecParametersWidth(this._handle)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
get height() {
|
|
60
|
+
return binding.getCodecParametersHeight(this._handle)
|
|
61
|
+
}
|
|
62
|
+
|
|
43
63
|
fromContext(context) {
|
|
44
64
|
binding.codecParametersFromContext(this._handle, context._handle)
|
|
45
65
|
}
|
|
@@ -47,4 +67,22 @@ module.exports = class FFmpegCodecParameters {
|
|
|
47
67
|
toContext(context) {
|
|
48
68
|
binding.codecParametersToContext(context._handle, this._handle)
|
|
49
69
|
}
|
|
70
|
+
|
|
71
|
+
[Symbol.for('bare.inspect')]() {
|
|
72
|
+
return {
|
|
73
|
+
__proto__: { constructor: FFmpegCodecParameters },
|
|
74
|
+
codecType: this.codecType,
|
|
75
|
+
codecId: this.codecId,
|
|
76
|
+
width: this.width,
|
|
77
|
+
height: this.height,
|
|
78
|
+
bitRate: this.bitRate,
|
|
79
|
+
bitsPerCodedSample: this.bitsPerCodedSample,
|
|
80
|
+
bitsPerRawSample: this.bitsPerRawSample,
|
|
81
|
+
format: this.format,
|
|
82
|
+
sampleRate: this.sampleRate,
|
|
83
|
+
nbChannels: this.nbChannels,
|
|
84
|
+
channelLayout: this.channelLayout,
|
|
85
|
+
frameRate: this.frameRate
|
|
86
|
+
}
|
|
87
|
+
}
|
|
50
88
|
}
|
package/lib/codec.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import FFmpegDecoder from './decoder'
|
|
2
|
+
import FFmpegEncoder from './encoder'
|
|
3
|
+
|
|
4
|
+
declare class FFmpegCodec {
|
|
5
|
+
readonly id: number
|
|
6
|
+
readonly decoder: FFmpegDecoder
|
|
7
|
+
readonly encoder: FFmpegEncoder
|
|
8
|
+
|
|
9
|
+
constructor(id: number)
|
|
10
|
+
|
|
11
|
+
static for(id: number): FFmpegCodec
|
|
12
|
+
|
|
13
|
+
static MJPEG: FFmpegCodec
|
|
14
|
+
static H264: FFmpegCodec
|
|
15
|
+
static AAC: FFmpegCodec
|
|
16
|
+
static OPUS: FFmpegCodec
|
|
17
|
+
static AV1: FFmpegCodec
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export = FFmpegCodec
|
package/lib/codec.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const Decoder = require('./decoder')
|
|
2
2
|
const Encoder = require('./encoder')
|
|
3
3
|
const constants = require('./constants')
|
|
4
|
+
const binding = require('../binding')
|
|
4
5
|
|
|
5
6
|
const codecs = new Map()
|
|
6
7
|
|
|
@@ -25,6 +26,19 @@ module.exports = class FFmpegCodec {
|
|
|
25
26
|
return this._encoder
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
get name() {
|
|
30
|
+
return binding.getCodecNameByID(this._id)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[Symbol.for('bare.inspect')]() {
|
|
34
|
+
return {
|
|
35
|
+
__proto__: { constructor: FFmpegCodec },
|
|
36
|
+
id: this.id,
|
|
37
|
+
name: this.name
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** @return {FFmpegCodec} */
|
|
28
42
|
static for(id) {
|
|
29
43
|
let codec = codecs.get(id)
|
|
30
44
|
if (codec === undefined) {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
declare const constants: {
|
|
2
|
+
codecs: {
|
|
3
|
+
MJPEG: number
|
|
4
|
+
H264: number
|
|
5
|
+
AAC: number
|
|
6
|
+
OPUS: number
|
|
7
|
+
AV1: number
|
|
8
|
+
}
|
|
9
|
+
pixelFormats: {
|
|
10
|
+
RGBA: number
|
|
11
|
+
RGB24: number
|
|
12
|
+
YUVJ420P: number
|
|
13
|
+
UYVY422: number
|
|
14
|
+
YUV420P: number
|
|
15
|
+
}
|
|
16
|
+
mediaTypes: {
|
|
17
|
+
UNKNOWN: number
|
|
18
|
+
VIDEO: number
|
|
19
|
+
AUDIO: number
|
|
20
|
+
DATA: number
|
|
21
|
+
SUBTITLE: number
|
|
22
|
+
ATTACHEMENT: number
|
|
23
|
+
NB: number
|
|
24
|
+
}
|
|
25
|
+
sampleFormats: {
|
|
26
|
+
NONE: number
|
|
27
|
+
U8: number
|
|
28
|
+
S16: number
|
|
29
|
+
S32: number
|
|
30
|
+
S64: number
|
|
31
|
+
FLT: number
|
|
32
|
+
DBL: number
|
|
33
|
+
U8P: number
|
|
34
|
+
S16P: number
|
|
35
|
+
S32P: number
|
|
36
|
+
S64P: number
|
|
37
|
+
FLTP: number
|
|
38
|
+
DBLP: number
|
|
39
|
+
NB: number
|
|
40
|
+
}
|
|
41
|
+
channelLayouts: {
|
|
42
|
+
MONO: number
|
|
43
|
+
STEREO: number
|
|
44
|
+
QUAD: number
|
|
45
|
+
SURROUND: number
|
|
46
|
+
2_1: number
|
|
47
|
+
5_0: number
|
|
48
|
+
5_1: number
|
|
49
|
+
7_1: number
|
|
50
|
+
// Aliases
|
|
51
|
+
2.1: number
|
|
52
|
+
'5.0': number
|
|
53
|
+
5.1: number
|
|
54
|
+
7.1: number
|
|
55
|
+
}
|
|
56
|
+
pictureTypes: {
|
|
57
|
+
NONE: number
|
|
58
|
+
I: number
|
|
59
|
+
P: number
|
|
60
|
+
B: number
|
|
61
|
+
S: number
|
|
62
|
+
SI: number
|
|
63
|
+
SP: number
|
|
64
|
+
BI: number
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function toPixelFormat(format: string | number): number
|
|
69
|
+
|
|
70
|
+
export function toSampleFormat(format: string | number): number
|
|
71
|
+
|
|
72
|
+
export function toChannelLayout(layout: string | number): number
|
|
73
|
+
|
|
74
|
+
export default constants
|
package/lib/constants.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const binding = require('../binding')
|
|
2
2
|
const errors = require('./errors')
|
|
3
|
-
const ChannelLayout = require('./channel-layout')
|
|
4
3
|
|
|
5
4
|
module.exports = exports = {
|
|
6
5
|
codecs: {
|
|
@@ -8,7 +7,9 @@ module.exports = exports = {
|
|
|
8
7
|
H264: binding.AV_CODEC_ID_H264,
|
|
9
8
|
AAC: binding.AV_CODEC_ID_AAC,
|
|
10
9
|
OPUS: binding.AV_CODEC_ID_OPUS,
|
|
11
|
-
AV1: binding.AV_CODEC_ID_AV1
|
|
10
|
+
AV1: binding.AV_CODEC_ID_AV1,
|
|
11
|
+
FLAC: binding.AV_CODEC_ID_FLAC,
|
|
12
|
+
MP3: binding.AV_CODEC_ID_MP3
|
|
12
13
|
},
|
|
13
14
|
pixelFormats: {
|
|
14
15
|
RGBA: binding.AV_PIX_FMT_RGBA,
|
|
@@ -57,7 +58,7 @@ module.exports = exports = {
|
|
|
57
58
|
5.1: binding.AV_CH_LAYOUT_5POINT1,
|
|
58
59
|
7.1: binding.AV_CH_LAYOUT_7POINT1
|
|
59
60
|
},
|
|
60
|
-
|
|
61
|
+
pictureTypes: {
|
|
61
62
|
NONE: binding.AV_PICTURE_TYPE_NONE,
|
|
62
63
|
I: binding.AV_PICTURE_TYPE_I,
|
|
63
64
|
P: binding.AV_PICTURE_TYPE_P,
|
|
@@ -66,6 +67,51 @@ module.exports = exports = {
|
|
|
66
67
|
SI: binding.AV_PICTURE_TYPE_SI,
|
|
67
68
|
SP: binding.AV_PICTURE_TYPE_SP,
|
|
68
69
|
BI: binding.AV_PICTURE_TYPE_BI
|
|
70
|
+
},
|
|
71
|
+
logLevels: {
|
|
72
|
+
QUIET: binding.AV_LOG_QUIET,
|
|
73
|
+
PANIC: binding.AV_LOG_PANIC,
|
|
74
|
+
FATAL: binding.AV_LOG_FATAL,
|
|
75
|
+
ERROR: binding.AV_LOG_ERROR,
|
|
76
|
+
WARNING: binding.AV_LOG_WARNING,
|
|
77
|
+
INFO: binding.AV_LOG_INFO,
|
|
78
|
+
VERBOSE: binding.AV_LOG_VERBOSE,
|
|
79
|
+
DEBUG: binding.AV_LOG_DEBUG,
|
|
80
|
+
TRACE: binding.AV_LOG_TRACE
|
|
81
|
+
},
|
|
82
|
+
codecFlags: {
|
|
83
|
+
COPY_OPAQUE: binding.AV_CODEC_FLAG_COPY_OPAQUE,
|
|
84
|
+
FRAME_DURATION: binding.AV_CODEC_FLAG_FRAME_DURATION,
|
|
85
|
+
PASS1: binding.AV_CODEC_FLAG_PASS1,
|
|
86
|
+
PASS2: binding.AV_CODEC_FLAG_PASS2,
|
|
87
|
+
LOOP_FILTER: binding.AV_CODEC_FLAG_LOOP_FILTER,
|
|
88
|
+
GRAY: binding.AV_CODEC_FLAG_GRAY,
|
|
89
|
+
PSNR: binding.AV_CODEC_FLAG_PSNR,
|
|
90
|
+
INTERLACED_DCT: binding.AV_CODEC_FLAG_INTERLACED_DCT,
|
|
91
|
+
LOW_DELAY: binding.AV_CODEC_FLAG_LOW_DELAY,
|
|
92
|
+
GLOBAL_HEADER: binding.AV_CODEC_FLAG_GLOBAL_HEADER,
|
|
93
|
+
BITEXACT: binding.AV_CODEC_FLAG_BITEXACT,
|
|
94
|
+
AC_PRED: binding.AV_CODEC_FLAG_AC_PRED,
|
|
95
|
+
INTERLACED_ME: binding.AV_CODEC_FLAG_INTERLACED_ME,
|
|
96
|
+
CLOSED_GOP: binding.AV_CODEC_FLAG_CLOSED_GOP
|
|
97
|
+
},
|
|
98
|
+
formatFlags: {
|
|
99
|
+
SHOW_IDS: binding.AVFMT_SHOW_IDS,
|
|
100
|
+
GENERIC_INDEX: binding.AVFMT_GENERIC_INDEX,
|
|
101
|
+
TS_DISCONT: binding.AVFMT_TS_DISCONT,
|
|
102
|
+
NOBINSEARCH: binding.AVFMT_NOBINSEARCH,
|
|
103
|
+
NOGENSEARCH: binding.AVFMT_NOGENSEARCH,
|
|
104
|
+
NO_BYTE_SEEK: binding.AVFMT_NO_BYTE_SEEK,
|
|
105
|
+
SEEK_TO_PTS: binding.AVFMT_SEEK_TO_PTS,
|
|
106
|
+
GLOBALHEADER: binding.AVFMT_GLOBALHEADER,
|
|
107
|
+
VARIABLE_FPS: binding.AVFMT_VARIABLE_FPS,
|
|
108
|
+
NODIMENSIONS: binding.AVFMT_NODIMENSIONS,
|
|
109
|
+
NOSTREAMS: binding.AVFMT_NOSTREAMS,
|
|
110
|
+
TS_NONSTRICT: binding.AVFMT_TS_NONSTRICT,
|
|
111
|
+
TS_NEGATIVE: binding.AVFMT_TS_NEGATIVE,
|
|
112
|
+
NOFILE: binding.AVFMT_NOFILE,
|
|
113
|
+
NEEDNUMBER: binding.AVFMT_NEEDNUMBER,
|
|
114
|
+
NOTIMESTAMPS: binding.AVFMT_NOTIMESTAMPS
|
|
69
115
|
}
|
|
70
116
|
}
|
|
71
117
|
|
package/lib/decoder.d.ts
ADDED
package/lib/dictionary.js
CHANGED
package/lib/encoder.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import FFmpegIOContext from './io-context'
|
|
2
|
+
import FFmpegStream from './stream'
|
|
3
|
+
import FFmpegPacket from './packet'
|
|
4
|
+
import FFmpegCodec from './codec'
|
|
5
|
+
import FFmpegOutputFormat from './output-format'
|
|
6
|
+
import FFmpegInputFormat from './input-format'
|
|
7
|
+
import FFmpegDictionary from './dictionary'
|
|
8
|
+
|
|
9
|
+
declare class FFmpegFormatContext {
|
|
10
|
+
readonly io: FFmpegIOContext
|
|
11
|
+
readonly streams: FFmpegStream[]
|
|
12
|
+
|
|
13
|
+
constructor(io: FFmpegIOContext)
|
|
14
|
+
|
|
15
|
+
readFrame(packet: FFmpegPacket): boolean
|
|
16
|
+
|
|
17
|
+
getBestStreamIndex(type: number): number
|
|
18
|
+
getStream(index: number): FFmpegStream
|
|
19
|
+
getBestStream(type: number): FFmpegStream | null
|
|
20
|
+
|
|
21
|
+
destroy(): void
|
|
22
|
+
[Symbol.dispose](): void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare class FFmpegInputFormatContext extends FFmpegFormatContext {
|
|
26
|
+
constructor(io: FFmpegIOContext)
|
|
27
|
+
constructor(input: FFmpegInputFormat, option?: FFmpegDictionary, url?: string)
|
|
28
|
+
|
|
29
|
+
destroy(): void
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare class FFmpegOutputFormatContext extends FFmpegFormatContext {
|
|
33
|
+
constructor(format: FFmpegOutputFormat | string, io: FFmpegIOContext)
|
|
34
|
+
|
|
35
|
+
createStream(codec: FFmpegCodec): FFmpegStream
|
|
36
|
+
|
|
37
|
+
destroy(): void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
FFmpegInputFormatContext as InputFormatContext,
|
|
42
|
+
FFmpegOutputFormatContext as OutputFormatContext
|
|
43
|
+
}
|
package/lib/format-context.js
CHANGED
|
@@ -4,6 +4,7 @@ const OutputFormat = require('./output-format')
|
|
|
4
4
|
const IOContext = require('./io-context')
|
|
5
5
|
const InputFormat = require('./input-format')
|
|
6
6
|
const Dictionary = require('./dictionary')
|
|
7
|
+
/** @typedef {import('./packet')} Packet */
|
|
7
8
|
|
|
8
9
|
class FFmpegFormatContext {
|
|
9
10
|
constructor(io) {
|
|
@@ -42,8 +43,9 @@ class FFmpegFormatContext {
|
|
|
42
43
|
return this._streams[index]
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
/** @returns {Stream|null} */
|
|
45
47
|
getBestStream(type) {
|
|
46
|
-
if (this._streams.length
|
|
48
|
+
if (this._streams.length === 0) {
|
|
47
49
|
return null
|
|
48
50
|
}
|
|
49
51
|
|
|
@@ -109,6 +111,10 @@ exports.InputFormatContext = class FFmpegInputFormatContext extends (
|
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
|
|
114
|
+
dump(printIdx = 0, printUrl = '') {
|
|
115
|
+
binding.dumpFormatContext(this._handle, false, printIdx, printUrl)
|
|
116
|
+
}
|
|
117
|
+
|
|
112
118
|
destroy() {
|
|
113
119
|
super.destroy()
|
|
114
120
|
|
|
@@ -126,6 +132,7 @@ exports.OutputFormatContext = class FFmpegOutputFormatContext extends (
|
|
|
126
132
|
if (typeof format === 'string') format = new OutputFormat(format)
|
|
127
133
|
|
|
128
134
|
this._handle = binding.openOutputFormatContext(format._handle, io._handle)
|
|
135
|
+
this._isOutput = true
|
|
129
136
|
}
|
|
130
137
|
|
|
131
138
|
destroy() {
|
|
@@ -135,13 +142,29 @@ exports.OutputFormatContext = class FFmpegOutputFormatContext extends (
|
|
|
135
142
|
this._handle = null
|
|
136
143
|
}
|
|
137
144
|
|
|
138
|
-
createStream(
|
|
139
|
-
const stream = new Stream(
|
|
140
|
-
binding.createFormatContextStream(this._handle, codec._handle)
|
|
141
|
-
)
|
|
145
|
+
createStream() {
|
|
146
|
+
const stream = new Stream(binding.createFormatContextStream(this._handle))
|
|
142
147
|
|
|
143
148
|
this._streams.push(stream)
|
|
144
149
|
|
|
145
150
|
return stream
|
|
146
151
|
}
|
|
152
|
+
|
|
153
|
+
/** @param {Dictionary} [options] format options */
|
|
154
|
+
writeHeader(options) {
|
|
155
|
+
binding.writeFormatContextHeader(this._handle, options?._handle)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** @param {Packet} packet */
|
|
159
|
+
writeFrame(packet) {
|
|
160
|
+
binding.writeFormatContextFrame(this._handle, packet._handle)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
writeTrailer() {
|
|
164
|
+
binding.writeFormatContextTrailer(this._handle)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
dump(printIdx = 0, printUrl = '') {
|
|
168
|
+
binding.dumpFormatContext(this._handle, true, printIdx, printUrl)
|
|
169
|
+
}
|
|
147
170
|
}
|