bare-ffmpeg 1.0.0-30 → 1.0.0-32
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/README.md +17 -15
- package/binding.cc +21 -0
- package/index.js +1 -4
- package/lib/codec-context.js +7 -33
- package/lib/codec-parameters.js +6 -23
- package/lib/constants.js +4 -7
- package/lib/errors.js +3 -15
- package/lib/filter-graph.js +1 -6
- package/lib/filter-inout.js +1 -4
- package/lib/format-context.js +4 -15
- package/lib/frame.js +1 -4
- package/lib/image.js +1 -3
- package/lib/input-format.js +5 -0
- package/lib/output-format.js +5 -0
- package/lib/packet.js +1 -6
- package/lib/rational.js +1 -4
- package/lib/resampler.js +1 -5
- package/lib/samples.js +2 -13
- package/lib/scaler.js +1 -7
- package/lib/stream.js +2 -8
- package/package.json +2 -2
- 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/README.md
CHANGED
|
@@ -536,25 +536,19 @@ Examples:
|
|
|
536
536
|
```js
|
|
537
537
|
const codecCtx = new ffmpeg.CodecContext(ffmpeg.Codec.AV1.encoder)
|
|
538
538
|
|
|
539
|
-
const pixelFormats = codecCtx.getSupportedConfig(
|
|
540
|
-
ffmpeg.constants.codecConfig.PIX_FORMAT
|
|
541
|
-
)
|
|
539
|
+
const pixelFormats = codecCtx.getSupportedConfig(ffmpeg.constants.codecConfig.PIX_FORMAT)
|
|
542
540
|
if (pixelFormats) {
|
|
543
541
|
console.log('Supported pixel formats:', pixelFormats)
|
|
544
542
|
}
|
|
545
543
|
|
|
546
|
-
const frameRates = codecCtx.getSupportedConfig(
|
|
547
|
-
ffmpeg.constants.codecConfig.FRAME_RATE
|
|
548
|
-
)
|
|
544
|
+
const frameRates = codecCtx.getSupportedConfig(ffmpeg.constants.codecConfig.FRAME_RATE)
|
|
549
545
|
if (frameRates) {
|
|
550
546
|
frameRates.forEach((rate) => {
|
|
551
547
|
console.log(`${rate.toNumber()} fps`)
|
|
552
548
|
})
|
|
553
549
|
}
|
|
554
550
|
|
|
555
|
-
const layouts = codecCtx.getSupportedConfig(
|
|
556
|
-
ffmpeg.constants.codecConfig.CHANNEL_LAYOUT
|
|
557
|
-
)
|
|
551
|
+
const layouts = codecCtx.getSupportedConfig(ffmpeg.constants.codecConfig.CHANNEL_LAYOUT)
|
|
558
552
|
if (layouts) {
|
|
559
553
|
console.log('Supported channel layouts:', layouts)
|
|
560
554
|
}
|
|
@@ -839,6 +833,12 @@ Gets the MIME type for this input format.
|
|
|
839
833
|
|
|
840
834
|
**Returns**: `string` - The MIME type (e.g., `'audio/webm,audio/x-matroska,video/webm,video/x-matroska'`)
|
|
841
835
|
|
|
836
|
+
##### `InputFormat.name`
|
|
837
|
+
|
|
838
|
+
Returns format name
|
|
839
|
+
|
|
840
|
+
**Returns**: `string` - The short-name (e.g., `webm`)
|
|
841
|
+
|
|
842
842
|
#### Example
|
|
843
843
|
|
|
844
844
|
```js
|
|
@@ -883,6 +883,12 @@ Gets the MIME type for this output format.
|
|
|
883
883
|
|
|
884
884
|
**Returns**: `string` - The MIME type (e.g., `'video/webm'`, `'video/mp4'`)
|
|
885
885
|
|
|
886
|
+
##### `OutputFormat.name`
|
|
887
|
+
|
|
888
|
+
Returns format name
|
|
889
|
+
|
|
890
|
+
**Returns**: `string` - The short-name (e.g., `webm`)
|
|
891
|
+
|
|
886
892
|
#### Example
|
|
887
893
|
|
|
888
894
|
```js
|
|
@@ -1782,9 +1788,7 @@ Parameters:
|
|
|
1782
1788
|
**Returns**: `string` - The sample format name
|
|
1783
1789
|
|
|
1784
1790
|
```js
|
|
1785
|
-
const name = ffmpeg.constants.getSampleFormatName(
|
|
1786
|
-
ffmpeg.constants.sampleFormats.S16
|
|
1787
|
-
)
|
|
1791
|
+
const name = ffmpeg.constants.getSampleFormatName(ffmpeg.constants.sampleFormats.S16)
|
|
1788
1792
|
console.log(name) // 's16'
|
|
1789
1793
|
```
|
|
1790
1794
|
|
|
@@ -1799,9 +1803,7 @@ Parameters:
|
|
|
1799
1803
|
**Returns**: `string` - The pixel format name
|
|
1800
1804
|
|
|
1801
1805
|
```js
|
|
1802
|
-
const name = ffmpeg.constants.getPixelFormatName(
|
|
1803
|
-
ffmpeg.constants.pixelFormats.RGB24
|
|
1804
|
-
)
|
|
1806
|
+
const name = ffmpeg.constants.getPixelFormatName(ffmpeg.constants.pixelFormats.RGB24)
|
|
1805
1807
|
console.log(name) // 'rgb24'
|
|
1806
1808
|
```
|
|
1807
1809
|
|
package/binding.cc
CHANGED
|
@@ -397,6 +397,15 @@ bare_ffmpeg_input_format_get_mime_type(
|
|
|
397
397
|
return context->handle->mime_type;
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
+
static std::string
|
|
401
|
+
bare_ffmpeg_input_format_get_name(
|
|
402
|
+
js_env_t *env,
|
|
403
|
+
js_receiver_t,
|
|
404
|
+
js_arraybuffer_span_of_t<bare_ffmpeg_input_format_t, 1> context
|
|
405
|
+
) {
|
|
406
|
+
return context->handle->name;
|
|
407
|
+
}
|
|
408
|
+
|
|
400
409
|
static js_arraybuffer_t
|
|
401
410
|
bare_ffmpeg_format_context_open_input_with_io(
|
|
402
411
|
js_env_t *env,
|
|
@@ -542,6 +551,15 @@ bare_ffmpeg_output_format_get_mime_type(
|
|
|
542
551
|
return context->handle->mime_type;
|
|
543
552
|
}
|
|
544
553
|
|
|
554
|
+
static std::string
|
|
555
|
+
bare_ffmpeg_output_format_get_name(
|
|
556
|
+
js_env_t *env,
|
|
557
|
+
js_receiver_t,
|
|
558
|
+
js_arraybuffer_span_of_t<bare_ffmpeg_output_format_t, 1> context
|
|
559
|
+
) {
|
|
560
|
+
return context->handle->name;
|
|
561
|
+
}
|
|
562
|
+
|
|
545
563
|
static void
|
|
546
564
|
bare_ffmpeg_format_context_close_output(
|
|
547
565
|
js_env_t *env,
|
|
@@ -4052,11 +4070,13 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
|
|
|
4052
4070
|
V("getInputFormatFlags", bare_ffmpeg_input_format_get_flags)
|
|
4053
4071
|
V("getInputFormatExtensions", bare_ffmpeg_input_format_get_extensions)
|
|
4054
4072
|
V("getInputFormatMimeType", bare_ffmpeg_input_format_get_mime_type)
|
|
4073
|
+
V("getInputFormatName", bare_ffmpeg_input_format_get_name)
|
|
4055
4074
|
|
|
4056
4075
|
V("initOutputFormat", bare_ffmpeg_output_format_init)
|
|
4057
4076
|
V("getOutputFormatFlags", bare_ffmpeg_output_format_get_flags)
|
|
4058
4077
|
V("getOutputFormatExtensions", bare_ffmpeg_output_format_get_extensions)
|
|
4059
4078
|
V("getOutputFormatMimeType", bare_ffmpeg_output_format_get_mime_type)
|
|
4079
|
+
V("getOutputFormatName", bare_ffmpeg_output_format_get_name)
|
|
4060
4080
|
|
|
4061
4081
|
V("openInputFormatContextWithIO", bare_ffmpeg_format_context_open_input_with_io)
|
|
4062
4082
|
V("openInputFormatContextWithFormat", bare_ffmpeg_format_context_open_input_with_format)
|
|
@@ -4362,6 +4382,7 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
|
|
|
4362
4382
|
V(AV_PIX_FMT_NV12)
|
|
4363
4383
|
V(AV_PIX_FMT_NV21)
|
|
4364
4384
|
V(AV_PIX_FMT_NV24)
|
|
4385
|
+
V(AV_PIX_FMT_VIDEOTOOLBOX)
|
|
4365
4386
|
|
|
4366
4387
|
V(AVMEDIA_TYPE_UNKNOWN)
|
|
4367
4388
|
V(AVMEDIA_TYPE_VIDEO)
|
package/index.js
CHANGED
|
@@ -6,10 +6,7 @@ const CodecParameters = require('./lib/codec-parameters')
|
|
|
6
6
|
const Decoder = require('./lib/decoder')
|
|
7
7
|
const Dictionary = require('./lib/dictionary')
|
|
8
8
|
const Encoder = require('./lib/encoder')
|
|
9
|
-
const {
|
|
10
|
-
InputFormatContext,
|
|
11
|
-
OutputFormatContext
|
|
12
|
-
} = require('./lib/format-context')
|
|
9
|
+
const { InputFormatContext, OutputFormatContext } = require('./lib/format-context')
|
|
13
10
|
const Filter = require('./lib/filter')
|
|
14
11
|
const FilterContext = require('./lib/filter-context')
|
|
15
12
|
const FilterGraph = require('./lib/filter-graph')
|
package/lib/codec-context.js
CHANGED
|
@@ -61,11 +61,7 @@ module.exports = class FFmpegCodecContext {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
set timeBase(value) {
|
|
64
|
-
binding.setCodecContextTimeBase(
|
|
65
|
-
this._handle,
|
|
66
|
-
value.numerator,
|
|
67
|
-
value.denominator
|
|
68
|
-
)
|
|
64
|
+
binding.setCodecContextTimeBase(this._handle, value.numerator, value.denominator)
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
get frameRate() {
|
|
@@ -74,11 +70,7 @@ module.exports = class FFmpegCodecContext {
|
|
|
74
70
|
}
|
|
75
71
|
|
|
76
72
|
set frameRate(value) {
|
|
77
|
-
binding.setCodecContextFramerate(
|
|
78
|
-
this._handle,
|
|
79
|
-
value.numerator,
|
|
80
|
-
value.denominator
|
|
81
|
-
)
|
|
73
|
+
binding.setCodecContextFramerate(this._handle, value.numerator, value.denominator)
|
|
82
74
|
}
|
|
83
75
|
|
|
84
76
|
get channelLayout() {
|
|
@@ -86,10 +78,7 @@ module.exports = class FFmpegCodecContext {
|
|
|
86
78
|
}
|
|
87
79
|
|
|
88
80
|
set channelLayout(value) {
|
|
89
|
-
binding.setCodecContextChannelLayout(
|
|
90
|
-
this._handle,
|
|
91
|
-
ChannelLayout.from(value)._handle
|
|
92
|
-
)
|
|
81
|
+
binding.setCodecContextChannelLayout(this._handle, ChannelLayout.from(value)._handle)
|
|
93
82
|
}
|
|
94
83
|
|
|
95
84
|
get gopSize() {
|
|
@@ -113,12 +102,7 @@ module.exports = class FFmpegCodecContext {
|
|
|
113
102
|
}
|
|
114
103
|
|
|
115
104
|
set extraData(value) {
|
|
116
|
-
binding.setCodecContextExtraData(
|
|
117
|
-
this._handle,
|
|
118
|
-
value.buffer,
|
|
119
|
-
value.byteOffset,
|
|
120
|
-
value.byteLength
|
|
121
|
-
)
|
|
105
|
+
binding.setCodecContextExtraData(this._handle, value.buffer, value.byteOffset, value.byteLength)
|
|
122
106
|
}
|
|
123
107
|
|
|
124
108
|
get frameSize() {
|
|
@@ -176,10 +160,7 @@ module.exports = class FFmpegCodecContext {
|
|
|
176
160
|
|
|
177
161
|
getSupportedConfig(config) {
|
|
178
162
|
if (config === codecConfig.FRAME_RATE) {
|
|
179
|
-
const data = binding.getSupportedFrameRates(
|
|
180
|
-
this._handle,
|
|
181
|
-
this._codec._handle
|
|
182
|
-
)
|
|
163
|
+
const data = binding.getSupportedFrameRates(this._handle, this._codec._handle)
|
|
183
164
|
if (!data || data.length === 0) return null
|
|
184
165
|
|
|
185
166
|
const view = new Int32Array(data)
|
|
@@ -191,20 +172,13 @@ module.exports = class FFmpegCodecContext {
|
|
|
191
172
|
}
|
|
192
173
|
|
|
193
174
|
if (config === codecConfig.CHANNEL_LAYOUT) {
|
|
194
|
-
const handles = binding.getSupportedChannelLayouts(
|
|
195
|
-
this._handle,
|
|
196
|
-
this._codec._handle
|
|
197
|
-
)
|
|
175
|
+
const handles = binding.getSupportedChannelLayouts(this._handle, this._codec._handle)
|
|
198
176
|
if (!handles || handles.length === 0) return null
|
|
199
177
|
|
|
200
178
|
return handles.map((handle) => new ChannelLayout(handle))
|
|
201
179
|
}
|
|
202
180
|
|
|
203
|
-
const data = binding.getSupportedConfig(
|
|
204
|
-
this._handle,
|
|
205
|
-
this._codec._handle,
|
|
206
|
-
config
|
|
207
|
-
)
|
|
181
|
+
const data = binding.getSupportedConfig(this._handle, this._codec._handle, config)
|
|
208
182
|
|
|
209
183
|
if (config === codecConfig.SAMPLE_RATE && !data) {
|
|
210
184
|
return null
|
package/lib/codec-parameters.js
CHANGED
|
@@ -43,33 +43,21 @@ module.exports = class FFmpegCodecParameters {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
get sampleAspectRatio() {
|
|
46
|
-
const view = new Int32Array(
|
|
47
|
-
binding.getCodecParametersSampleAspectRatio(this._handle)
|
|
48
|
-
)
|
|
46
|
+
const view = new Int32Array(binding.getCodecParametersSampleAspectRatio(this._handle))
|
|
49
47
|
return new Rational(view[0], view[1])
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
set sampleAspectRatio(ratio) {
|
|
53
|
-
binding.setCodecParametersSampleAspectRatio(
|
|
54
|
-
this._handle,
|
|
55
|
-
ratio.numerator,
|
|
56
|
-
ratio.denominator
|
|
57
|
-
)
|
|
51
|
+
binding.setCodecParametersSampleAspectRatio(this._handle, ratio.numerator, ratio.denominator)
|
|
58
52
|
}
|
|
59
53
|
|
|
60
54
|
get frameRate() {
|
|
61
|
-
const view = new Int32Array(
|
|
62
|
-
binding.getCodecParametersFramerate(this._handle)
|
|
63
|
-
)
|
|
55
|
+
const view = new Int32Array(binding.getCodecParametersFramerate(this._handle))
|
|
64
56
|
return new Rational(view[0], view[1])
|
|
65
57
|
}
|
|
66
58
|
|
|
67
59
|
set frameRate(rate) {
|
|
68
|
-
binding.setCodecParametersFramerate(
|
|
69
|
-
this._handle,
|
|
70
|
-
rate.numerator,
|
|
71
|
-
rate.denominator
|
|
72
|
-
)
|
|
60
|
+
binding.setCodecParametersFramerate(this._handle, rate.numerator, rate.denominator)
|
|
73
61
|
}
|
|
74
62
|
|
|
75
63
|
get frameSize() {
|
|
@@ -145,16 +133,11 @@ module.exports = class FFmpegCodecParameters {
|
|
|
145
133
|
}
|
|
146
134
|
|
|
147
135
|
get channelLayout() {
|
|
148
|
-
return new ChannelLayout(
|
|
149
|
-
binding.getCodecParametersChannelLayout(this._handle)
|
|
150
|
-
)
|
|
136
|
+
return new ChannelLayout(binding.getCodecParametersChannelLayout(this._handle))
|
|
151
137
|
}
|
|
152
138
|
|
|
153
139
|
set channelLayout(value) {
|
|
154
|
-
binding.setCodecParametersChannelLayout(
|
|
155
|
-
this._handle,
|
|
156
|
-
ChannelLayout.from(value)._handle
|
|
157
|
-
)
|
|
140
|
+
binding.setCodecParametersChannelLayout(this._handle, ChannelLayout.from(value)._handle)
|
|
158
141
|
}
|
|
159
142
|
|
|
160
143
|
get width() {
|
package/lib/constants.js
CHANGED
|
@@ -3,10 +3,7 @@ const errors = require('./errors')
|
|
|
3
3
|
|
|
4
4
|
function makeTag(a, b, c, d) {
|
|
5
5
|
return (
|
|
6
|
-
a.charCodeAt(0) |
|
|
7
|
-
(b.charCodeAt(0) << 8) |
|
|
8
|
-
(c.charCodeAt(0) << 16) |
|
|
9
|
-
(d.charCodeAt(0) << 24)
|
|
6
|
+
a.charCodeAt(0) | (b.charCodeAt(0) << 8) | (c.charCodeAt(0) << 16) | (d.charCodeAt(0) << 24)
|
|
10
7
|
)
|
|
11
8
|
}
|
|
12
9
|
|
|
@@ -41,7 +38,8 @@ module.exports = exports = {
|
|
|
41
38
|
YUV420P: binding.AV_PIX_FMT_YUV420P,
|
|
42
39
|
NV12: binding.AV_PIX_FMT_NV12,
|
|
43
40
|
NV21: binding.AV_PIX_FMT_NV21,
|
|
44
|
-
NV24: binding.AV_PIX_FMT_NV24
|
|
41
|
+
NV24: binding.AV_PIX_FMT_NV24,
|
|
42
|
+
VIDEOTOOLBOX: binding.AV_PIX_FMT_VIDEOTOOLBOX
|
|
45
43
|
},
|
|
46
44
|
mediaTypes: {
|
|
47
45
|
UNKNOWN: binding.AVMEDIA_TYPE_UNKNOWN,
|
|
@@ -181,8 +179,7 @@ module.exports = exports = {
|
|
|
181
179
|
IAMF_MIX_GAIN_PARAM: binding.AV_PKT_DATA_IAMF_MIX_GAIN_PARAM,
|
|
182
180
|
IAMF_DEMIXING_INFO_PARAM: binding.AV_PKT_DATA_IAMF_DEMIXING_INFO_PARAM,
|
|
183
181
|
IAMF_RECON_GAIN_INFO_PARAM: binding.AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM,
|
|
184
|
-
AMBIENT_VIEWING_ENVIRONMENT:
|
|
185
|
-
binding.AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT,
|
|
182
|
+
AMBIENT_VIEWING_ENVIRONMENT: binding.AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT,
|
|
186
183
|
FRAME_CROPPING: binding.AV_PKT_DATA_FRAME_CROPPING,
|
|
187
184
|
LCEVC: binding.AV_PKT_DATA_LCEVC,
|
|
188
185
|
'3D_REFERENCE_DISPLAYS': binding.AV_PKT_DATA_3D_REFERENCE_DISPLAYS,
|
package/lib/errors.js
CHANGED
|
@@ -13,26 +13,14 @@ module.exports = class FFmpegError extends Error {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
static UNKNOWN_PIXEL_FORMAT(msg) {
|
|
16
|
-
return new FFmpegError(
|
|
17
|
-
msg,
|
|
18
|
-
'UNKNOWN_PIXEL_FORMAT',
|
|
19
|
-
FFmpegError.UNKNOWN_PIXEL_FORMAT
|
|
20
|
-
)
|
|
16
|
+
return new FFmpegError(msg, 'UNKNOWN_PIXEL_FORMAT', FFmpegError.UNKNOWN_PIXEL_FORMAT)
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
static UNKNOWN_SAMPLE_FORMAT(msg) {
|
|
24
|
-
return new FFmpegError(
|
|
25
|
-
msg,
|
|
26
|
-
'UNKNOWN_SAMPLE_FORMAT',
|
|
27
|
-
FFmpegError.UNKNOWN_SAMPLE_FORMAT
|
|
28
|
-
)
|
|
20
|
+
return new FFmpegError(msg, 'UNKNOWN_SAMPLE_FORMAT', FFmpegError.UNKNOWN_SAMPLE_FORMAT)
|
|
29
21
|
}
|
|
30
22
|
|
|
31
23
|
static UNKNOWN_CHANNEL_LAYOUT(msg) {
|
|
32
|
-
return new FFmpegError(
|
|
33
|
-
msg,
|
|
34
|
-
'UNKNOWN_CHANNEL_LAYOUT',
|
|
35
|
-
FFmpegError.UNKNOWN_CHANNEL_LAYOUT
|
|
36
|
-
)
|
|
24
|
+
return new FFmpegError(msg, 'UNKNOWN_CHANNEL_LAYOUT', FFmpegError.UNKNOWN_CHANNEL_LAYOUT)
|
|
37
25
|
}
|
|
38
26
|
}
|
package/lib/filter-graph.js
CHANGED
|
@@ -21,12 +21,7 @@ module.exports = class FilterGraph {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
parse(filterDescription, inputs, outputs) {
|
|
24
|
-
binding.parseFilterGraph(
|
|
25
|
-
this._handle,
|
|
26
|
-
inputs._handle,
|
|
27
|
-
outputs._handle,
|
|
28
|
-
filterDescription
|
|
29
|
-
)
|
|
24
|
+
binding.parseFilterGraph(this._handle, inputs._handle, outputs._handle, filterDescription)
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
configure() {
|
package/lib/filter-inout.js
CHANGED
|
@@ -26,10 +26,7 @@ module.exports = class FilterInOut {
|
|
|
26
26
|
|
|
27
27
|
set filterContext(value) {
|
|
28
28
|
this._filterContext = value
|
|
29
|
-
return binding.setFilterInOutFilterContext(
|
|
30
|
-
this._handle,
|
|
31
|
-
this._filterContext._handle
|
|
32
|
-
)
|
|
29
|
+
return binding.setFilterInOutFilterContext(this._handle, this._filterContext._handle)
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
get padIdx() {
|
package/lib/format-context.js
CHANGED
|
@@ -49,10 +49,7 @@ class FFmpegFormatContext {
|
|
|
49
49
|
return null
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const bestIndex = binding.getFormatContextBestStreamIndex(
|
|
53
|
-
this._handle,
|
|
54
|
-
type
|
|
55
|
-
)
|
|
52
|
+
const bestIndex = binding.getFormatContextBestStreamIndex(this._handle, type)
|
|
56
53
|
|
|
57
54
|
if (bestIndex < 0 || bestIndex >= this._streams.length) {
|
|
58
55
|
return null
|
|
@@ -84,9 +81,7 @@ switch (Bare.platform) {
|
|
|
84
81
|
break
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
exports.InputFormatContext = class FFmpegInputFormatContext extends
|
|
88
|
-
FFmpegFormatContext
|
|
89
|
-
) {
|
|
84
|
+
exports.InputFormatContext = class FFmpegInputFormatContext extends FFmpegFormatContext {
|
|
90
85
|
constructor(io, options, url = defaultURL) {
|
|
91
86
|
if (io instanceof IOContext) {
|
|
92
87
|
super(io)
|
|
@@ -97,11 +92,7 @@ exports.InputFormatContext = class FFmpegInputFormatContext extends (
|
|
|
97
92
|
|
|
98
93
|
options = options || new Dictionary()
|
|
99
94
|
|
|
100
|
-
this._handle = binding.openInputFormatContextWithFormat(
|
|
101
|
-
io._handle,
|
|
102
|
-
options._handle,
|
|
103
|
-
url
|
|
104
|
-
)
|
|
95
|
+
this._handle = binding.openInputFormatContextWithFormat(io._handle, options._handle, url)
|
|
105
96
|
|
|
106
97
|
options.destroy()
|
|
107
98
|
}
|
|
@@ -128,9 +119,7 @@ exports.InputFormatContext = class FFmpegInputFormatContext extends (
|
|
|
128
119
|
}
|
|
129
120
|
}
|
|
130
121
|
|
|
131
|
-
exports.OutputFormatContext = class FFmpegOutputFormatContext extends
|
|
132
|
-
FFmpegFormatContext
|
|
133
|
-
) {
|
|
122
|
+
exports.OutputFormatContext = class FFmpegOutputFormatContext extends FFmpegFormatContext {
|
|
134
123
|
constructor(format, io) {
|
|
135
124
|
super(io)
|
|
136
125
|
|
package/lib/frame.js
CHANGED
|
@@ -45,10 +45,7 @@ module.exports = class FFmpegFrame {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
set channelLayout(value) {
|
|
48
|
-
binding.setFrameChannelLayout(
|
|
49
|
-
this._handle,
|
|
50
|
-
ChannelLayout.from(value)._handle
|
|
51
|
-
)
|
|
48
|
+
binding.setFrameChannelLayout(this._handle, ChannelLayout.from(value)._handle)
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
get nbSamples() {
|
package/lib/image.js
CHANGED
|
@@ -10,9 +10,7 @@ module.exports = class FFmpegImage {
|
|
|
10
10
|
this._height = height
|
|
11
11
|
this._align = align
|
|
12
12
|
|
|
13
|
-
this._data = Buffer.from(
|
|
14
|
-
binding.initImage(pixelFormat, width, height, align)
|
|
15
|
-
)
|
|
13
|
+
this._data = Buffer.from(binding.initImage(pixelFormat, width, height, align))
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
get pixelFormat() {
|
package/lib/input-format.js
CHANGED
|
@@ -40,9 +40,14 @@ module.exports = class FFmpegInputFormat {
|
|
|
40
40
|
return binding.getInputFormatMimeType(this._handle)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
get name() {
|
|
44
|
+
return binding.getInputFormatName(this._handle)
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
[Symbol.for('bare.inspect')]() {
|
|
44
48
|
return {
|
|
45
49
|
__proto__: { constructor: FFmpegInputFormat },
|
|
50
|
+
name: this.name,
|
|
46
51
|
flags: this.flags,
|
|
47
52
|
extensions: this.extensions,
|
|
48
53
|
mimeType: this.mimeType
|
package/lib/output-format.js
CHANGED
|
@@ -22,9 +22,14 @@ module.exports = class FFmpegOutputFormat {
|
|
|
22
22
|
return binding.getOutputFormatMimeType(this._handle)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
get name() {
|
|
26
|
+
return binding.getOutputFormatName(this._handle)
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
[Symbol.for('bare.inspect')]() {
|
|
26
30
|
return {
|
|
27
31
|
__proto__: { constructor: FFmpegOutputFormat },
|
|
32
|
+
name: this.name,
|
|
28
33
|
flags: this.flags,
|
|
29
34
|
extensions: this.extensions,
|
|
30
35
|
mimeType: this.mimeType
|
package/lib/packet.js
CHANGED
|
@@ -72,12 +72,7 @@ module.exports = class FFmpegPacket {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
set data(value) {
|
|
75
|
-
binding.setPacketData(
|
|
76
|
-
this._handle,
|
|
77
|
-
value.buffer,
|
|
78
|
-
value.byteOffset,
|
|
79
|
-
value.byteLength
|
|
80
|
-
)
|
|
75
|
+
binding.setPacketData(this._handle, value.buffer, value.byteOffset, value.byteLength)
|
|
81
76
|
}
|
|
82
77
|
|
|
83
78
|
get sideData() {
|
package/lib/rational.js
CHANGED
|
@@ -28,10 +28,7 @@ module.exports = class FFmpegRational {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
equals(other) {
|
|
31
|
-
return
|
|
32
|
-
this.numerator === other.numerator &&
|
|
33
|
-
this.denominator === other.denominator
|
|
34
|
-
)
|
|
31
|
+
return this.numerator === other.numerator && this.denominator === other.denominator
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
static from(num) {
|
package/lib/resampler.js
CHANGED
|
@@ -39,11 +39,7 @@ class FFmpegResampler {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
convert(inputFrame, outputFrame) {
|
|
42
|
-
return binding.convertResampler(
|
|
43
|
-
this._handle,
|
|
44
|
-
inputFrame._handle,
|
|
45
|
-
outputFrame._handle
|
|
46
|
-
)
|
|
42
|
+
return binding.convertResampler(this._handle, inputFrame._handle, outputFrame._handle)
|
|
47
43
|
}
|
|
48
44
|
|
|
49
45
|
flush(outputFrame) {
|
package/lib/samples.js
CHANGED
|
@@ -72,22 +72,11 @@ module.exports = class FFmpegSamples {
|
|
|
72
72
|
this._data = Buffer.allocUnsafe(len)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
binding.readSamples(
|
|
76
|
-
frame._handle,
|
|
77
|
-
this._data.buffer,
|
|
78
|
-
this._data.byteOffset,
|
|
79
|
-
this._noAlignment
|
|
80
|
-
)
|
|
75
|
+
binding.readSamples(frame._handle, this._data.buffer, this._data.byteOffset, this._noAlignment)
|
|
81
76
|
}
|
|
82
77
|
|
|
83
78
|
copy(frame, dstOffset = 0, srcOffset = 0) {
|
|
84
|
-
binding.copySamples(
|
|
85
|
-
frame._handle,
|
|
86
|
-
this._frame._handle,
|
|
87
|
-
dstOffset,
|
|
88
|
-
srcOffset,
|
|
89
|
-
this.nbSamples
|
|
90
|
-
)
|
|
79
|
+
binding.copySamples(frame._handle, this._frame._handle, dstOffset, srcOffset, this.nbSamples)
|
|
91
80
|
}
|
|
92
81
|
|
|
93
82
|
static bufferSize(format, nbChannels, nbSamples, noAlignment = false) {
|
package/lib/scaler.js
CHANGED
|
@@ -45,13 +45,7 @@ module.exports = class FFmpegScaler {
|
|
|
45
45
|
height = source.height
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
return binding.scaleScaler(
|
|
49
|
-
this._handle,
|
|
50
|
-
source._handle,
|
|
51
|
-
y,
|
|
52
|
-
height,
|
|
53
|
-
target._handle
|
|
54
|
-
)
|
|
48
|
+
return binding.scaleScaler(this._handle, source._handle, y, height, target._handle)
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
[Symbol.dispose]() {
|
package/lib/stream.js
CHANGED
|
@@ -8,9 +8,7 @@ module.exports = class FFmpegStream {
|
|
|
8
8
|
constructor(handle) {
|
|
9
9
|
this._handle = handle
|
|
10
10
|
|
|
11
|
-
this._codecParameters = new CodecParameters(
|
|
12
|
-
binding.getStreamCodecParameters(this._handle)
|
|
13
|
-
)
|
|
11
|
+
this._codecParameters = new CodecParameters(binding.getStreamCodecParameters(this._handle))
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
get id() {
|
|
@@ -48,11 +46,7 @@ module.exports = class FFmpegStream {
|
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
set avgFramerate(value) {
|
|
51
|
-
binding.setStreamAverageFramerate(
|
|
52
|
-
this._handle,
|
|
53
|
-
value.numerator,
|
|
54
|
-
value.denominator
|
|
55
|
-
)
|
|
49
|
+
binding.setStreamAverageFramerate(this._handle, value.numerator, value.denominator)
|
|
56
50
|
}
|
|
57
51
|
|
|
58
52
|
get duration() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-ffmpeg",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-32",
|
|
4
4
|
"description": "Low-level FFmpeg bindings for Bare",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
"cmake-harden": "^1.0.2",
|
|
39
39
|
"cmake-ports": "^1.5.0",
|
|
40
40
|
"prettier": "^3.3.3",
|
|
41
|
-
"prettier-config-
|
|
41
|
+
"prettier-config-holepunch": "^2.0.0"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|