bare-ffmpeg 1.0.0-31 → 1.0.0-33
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/CMakeLists.txt +31 -9
- package/README.md +65 -1771
- package/binding.cc +735 -1
- package/cmake/ports/ffmpeg/port.cmake +8 -9
- package/cmake/ports/libdrm/port.cmake +32 -0
- package/cmake/ports/libva/port.cmake +53 -0
- package/cmake/ports/x264/port.cmake +7 -2
- package/index.js +7 -4
- package/lib/codec-context.js +16 -33
- package/lib/codec-parameters.js +38 -23
- package/lib/codec.js +1 -0
- package/lib/constants.js +122 -8
- 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 +20 -4
- package/lib/hw-device-context.js +31 -0
- package/lib/hw-frames-constraints.js +54 -0
- package/lib/hw-frames-context.js +92 -0
- package/lib/image.js +1 -3
- 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/libva-drm.so.2 +0 -0
- package/prebuilds/linux-arm64/bare-ffmpeg/libva.so.2 +0 -0
- package/prebuilds/linux-arm64/bare-ffmpeg.bare +0 -0
- package/prebuilds/linux-x64/bare-ffmpeg/libva-drm.so.2 +0 -0
- package/prebuilds/linux-x64/bare-ffmpeg/libva.so.2 +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/lib/frame.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const binding = require('../binding')
|
|
2
2
|
const ChannelLayout = require('./channel-layout')
|
|
3
|
+
const HWFramesContext = require('./hw-frames-context')
|
|
3
4
|
const Rational = require('./rational')
|
|
5
|
+
const constants = require('./constants')
|
|
4
6
|
|
|
5
7
|
module.exports = class FFmpegFrame {
|
|
6
8
|
constructor() {
|
|
@@ -45,10 +47,7 @@ module.exports = class FFmpegFrame {
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
set channelLayout(value) {
|
|
48
|
-
binding.setFrameChannelLayout(
|
|
49
|
-
this._handle,
|
|
50
|
-
ChannelLayout.from(value)._handle
|
|
51
|
-
)
|
|
50
|
+
binding.setFrameChannelLayout(this._handle, ChannelLayout.from(value)._handle)
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
get nbSamples() {
|
|
@@ -96,10 +95,27 @@ module.exports = class FFmpegFrame {
|
|
|
96
95
|
binding.setFrameSampleRate(this._handle, value)
|
|
97
96
|
}
|
|
98
97
|
|
|
98
|
+
get hwFramesCtx() {
|
|
99
|
+
const handle = binding.getFrameHWFramesCtx(this._handle)
|
|
100
|
+
return handle ? HWFramesContext.from(handle) : null
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
set hwFramesCtx(hwFramesContext) {
|
|
104
|
+
binding.setFrameHWFramesCtx(this._handle, hwFramesContext._handle)
|
|
105
|
+
}
|
|
106
|
+
|
|
99
107
|
copyProperties(source) {
|
|
100
108
|
binding.copyFrameProperties(this._handle, source._handle)
|
|
101
109
|
}
|
|
102
110
|
|
|
111
|
+
transferData(destination) {
|
|
112
|
+
binding.transferFrameData(destination._handle, this._handle)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
hwMap(destination, flags = constants.hwFrameMapFlags.NONE) {
|
|
116
|
+
binding.mapFrame(destination._handle, this._handle, flags)
|
|
117
|
+
}
|
|
118
|
+
|
|
103
119
|
alloc() {
|
|
104
120
|
binding.allocFrame(this._handle, 32)
|
|
105
121
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const binding = require('../binding')
|
|
2
|
+
|
|
3
|
+
module.exports = class HWDeviceContext {
|
|
4
|
+
constructor(type, device = undefined, handle = undefined) {
|
|
5
|
+
if (handle) {
|
|
6
|
+
this._handle = handle
|
|
7
|
+
} else {
|
|
8
|
+
this._handle = binding.initHWDeviceContext(type, device)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static from(handle) {
|
|
13
|
+
if (handle == null) return null
|
|
14
|
+
return new HWDeviceContext(null, undefined, handle)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
destroy() {
|
|
18
|
+
binding.destroyHWDeviceContext(this._handle)
|
|
19
|
+
this._handle = null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[Symbol.dispose]() {
|
|
23
|
+
this.destroy()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[Symbol.for('bare.inspect')]() {
|
|
27
|
+
return {
|
|
28
|
+
__proto__: { constructor: HWDeviceContext }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const binding = require('../binding')
|
|
2
|
+
|
|
3
|
+
module.exports = class HWFramesConstraints {
|
|
4
|
+
constructor(handle) {
|
|
5
|
+
this._handle = handle
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get validSwFormats() {
|
|
9
|
+
return binding.getHWFramesConstraintsValidSwFormats(this._handle)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get validHwFormats() {
|
|
13
|
+
return binding.getHWFramesConstraintsValidHwFormats(this._handle)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get minWidth() {
|
|
17
|
+
return binding.getHWFramesConstraintsMinWidth(this._handle)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get maxWidth() {
|
|
21
|
+
return binding.getHWFramesConstraintsMaxWidth(this._handle)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get minHeight() {
|
|
25
|
+
return binding.getHWFramesConstraintsMinHeight(this._handle)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get maxHeight() {
|
|
29
|
+
return binding.getHWFramesConstraintsMaxHeight(this._handle)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Note: HWFramesConstraints is independently allocated by FFmpeg and must be
|
|
33
|
+
// explicitly freed. It is not owned by HWFramesContext.
|
|
34
|
+
destroy() {
|
|
35
|
+
binding.destroyHWFramesConstraints(this._handle)
|
|
36
|
+
this._handle = null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[Symbol.dispose]() {
|
|
40
|
+
this.destroy()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[Symbol.for('bare.inspect')]() {
|
|
44
|
+
return {
|
|
45
|
+
__proto__: { constructor: HWFramesConstraints },
|
|
46
|
+
validSwFormats: this.validSwFormats,
|
|
47
|
+
validHwFormats: this.validHwFormats,
|
|
48
|
+
minWidth: this.minWidth,
|
|
49
|
+
maxWidth: this.maxWidth,
|
|
50
|
+
minHeight: this.minHeight,
|
|
51
|
+
maxHeight: this.maxHeight
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const binding = require('../binding')
|
|
2
|
+
const HWFramesConstraints = require('./hw-frames-constraints')
|
|
3
|
+
|
|
4
|
+
module.exports = class HWFramesContext {
|
|
5
|
+
constructor(hwDeviceContext, format, swFormat, width, height, handle = undefined) {
|
|
6
|
+
if (handle) {
|
|
7
|
+
this._handle = handle
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
this._handle = binding.initHWFramesContext(
|
|
12
|
+
hwDeviceContext._handle,
|
|
13
|
+
format,
|
|
14
|
+
swFormat,
|
|
15
|
+
width,
|
|
16
|
+
height
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static from(handle) {
|
|
21
|
+
if (handle == null) return null
|
|
22
|
+
return new HWFramesContext(null, null, null, null, null, handle)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get format() {
|
|
26
|
+
return binding.getHWFramesContextFormat(this._handle)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
set format(value) {
|
|
30
|
+
binding.setHWFramesContextFormat(this._handle, value)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get swFormat() {
|
|
34
|
+
return binding.getHWFramesContextSWFormat(this._handle)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
set swFormat(value) {
|
|
38
|
+
binding.setHWFramesContextSWFormat(this._handle, value)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get width() {
|
|
42
|
+
return binding.getHWFramesContextWidth(this._handle)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
set width(value) {
|
|
46
|
+
binding.setHWFramesContextWidth(this._handle, value)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get height() {
|
|
50
|
+
return binding.getHWFramesContextHeight(this._handle)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
set height(value) {
|
|
54
|
+
binding.setHWFramesContextHeight(this._handle, value)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get initialPoolSize() {
|
|
58
|
+
return binding.getHWFramesContextInitialPoolSize(this._handle)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
set initialPoolSize(value) {
|
|
62
|
+
binding.setHWFramesContextInitialPoolSize(this._handle, value)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
getBuffer(frame) {
|
|
66
|
+
binding.getHWFramesContextBuffer(this._handle, frame._handle)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
getConstraints() {
|
|
70
|
+
const handle = binding.getHWFramesContextConstraints(this._handle)
|
|
71
|
+
return new HWFramesConstraints(handle)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
destroy() {
|
|
75
|
+
binding.destroyHWFramesContext(this._handle)
|
|
76
|
+
this._handle = null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[Symbol.dispose]() {
|
|
80
|
+
this.destroy()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
[Symbol.for('bare.inspect')]() {
|
|
84
|
+
return {
|
|
85
|
+
__proto__: { constructor: HWFramesContext },
|
|
86
|
+
format: this.format,
|
|
87
|
+
swFormat: this.swFormat,
|
|
88
|
+
width: this.width,
|
|
89
|
+
height: this.height
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
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-
|
|
3
|
+
"version": "1.0.0-33",
|
|
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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|