bare-ffmpeg 1.0.0-31 → 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 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
  }
@@ -1794,9 +1788,7 @@ Parameters:
1794
1788
  **Returns**: `string` - The sample format name
1795
1789
 
1796
1790
  ```js
1797
- const name = ffmpeg.constants.getSampleFormatName(
1798
- ffmpeg.constants.sampleFormats.S16
1799
- )
1791
+ const name = ffmpeg.constants.getSampleFormatName(ffmpeg.constants.sampleFormats.S16)
1800
1792
  console.log(name) // 's16'
1801
1793
  ```
1802
1794
 
@@ -1811,9 +1803,7 @@ Parameters:
1811
1803
  **Returns**: `string` - The pixel format name
1812
1804
 
1813
1805
  ```js
1814
- const name = ffmpeg.constants.getPixelFormatName(
1815
- ffmpeg.constants.pixelFormats.RGB24
1816
- )
1806
+ const name = ffmpeg.constants.getPixelFormatName(ffmpeg.constants.pixelFormats.RGB24)
1817
1807
  console.log(name) // 'rgb24'
1818
1808
  ```
1819
1809
 
package/binding.cc CHANGED
@@ -4382,6 +4382,7 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
4382
4382
  V(AV_PIX_FMT_NV12)
4383
4383
  V(AV_PIX_FMT_NV21)
4384
4384
  V(AV_PIX_FMT_NV24)
4385
+ V(AV_PIX_FMT_VIDEOTOOLBOX)
4385
4386
 
4386
4387
  V(AVMEDIA_TYPE_UNKNOWN)
4387
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')
@@ -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
@@ -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
  }
@@ -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() {
@@ -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() {
@@ -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/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-31",
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-standard": "^7.0.0"
41
+ "prettier-config-holepunch": "^2.0.0"
42
42
  }
43
43
  }