bare-ffmpeg 1.0.0-9 → 1.0.0
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 +32 -10
- package/README.md +65 -769
- package/binding.cc +5372 -0
- package/cmake/ports/ffmpeg/port.cmake +513 -0
- package/cmake/ports/libdrm/port.cmake +32 -0
- package/cmake/ports/libva/port.cmake +53 -0
- package/cmake/ports/opus/patches/01-windows-clang.patch +52 -0
- package/cmake/ports/opus/port.cmake +42 -0
- package/cmake/ports/svt-av1/port.cmake +42 -0
- package/cmake/ports/x264/patches/01-windows-clang.patch +33 -0
- package/cmake/ports/x264/port.cmake +162 -0
- package/index.js +28 -9
- package/lib/audio-fifo.js +47 -0
- package/lib/channel-layout.js +35 -0
- package/lib/codec-context.js +185 -7
- package/lib/codec-parameters.js +252 -4
- package/lib/codec.js +16 -0
- package/lib/constants.js +339 -12
- package/lib/dictionary.js +20 -0
- package/lib/errors.js +26 -0
- package/lib/filter-context.js +7 -0
- package/lib/filter-graph.js +42 -0
- package/lib/filter-inout.js +52 -0
- package/lib/filter.js +7 -0
- package/lib/format-context.js +42 -23
- package/lib/frame.js +81 -12
- 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 +14 -3
- package/lib/input-format.js +36 -2
- package/lib/io-context.js +29 -4
- package/lib/log.js +16 -0
- package/lib/output-format.js +33 -2
- package/lib/packet.js +143 -1
- package/lib/rational.js +46 -1
- package/lib/resampler.js +23 -17
- package/lib/samples.js +85 -0
- package/lib/scaler.js +3 -9
- package/lib/stream.js +51 -14
- package/package.json +9 -5
- 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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
include_guard(GLOBAL)
|
|
2
|
+
|
|
3
|
+
if(WIN32)
|
|
4
|
+
set(lib SvtAv1Enc.lib)
|
|
5
|
+
else()
|
|
6
|
+
set(lib libSvtAv1Enc.a)
|
|
7
|
+
endif()
|
|
8
|
+
|
|
9
|
+
set(args
|
|
10
|
+
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
|
|
11
|
+
-DBUILD_SHARED_LIBS=OFF
|
|
12
|
+
-DBUILD_TESTING=OFF
|
|
13
|
+
-DBUILD_APPS=OFF
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
if(WIN32)
|
|
17
|
+
list(APPEND args -DCOMPILE_C_ONLY=ON)
|
|
18
|
+
endif()
|
|
19
|
+
|
|
20
|
+
declare_port(
|
|
21
|
+
"gitlab:AOMediaCodec/SVT-AV1@2.3.0"
|
|
22
|
+
svt-av1
|
|
23
|
+
BYPRODUCTS lib/${lib}
|
|
24
|
+
ARGS ${args}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
add_library(svt-av1 STATIC IMPORTED GLOBAL)
|
|
28
|
+
|
|
29
|
+
add_dependencies(svt-av1 ${svt-av1})
|
|
30
|
+
|
|
31
|
+
set_target_properties(
|
|
32
|
+
svt-av1
|
|
33
|
+
PROPERTIES
|
|
34
|
+
IMPORTED_LOCATION "${svt-av1_PREFIX}/lib/${lib}"
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
file(MAKE_DIRECTORY "${svt-av1_PREFIX}/include")
|
|
38
|
+
|
|
39
|
+
target_include_directories(
|
|
40
|
+
svt-av1
|
|
41
|
+
INTERFACE "${svt-av1_PREFIX}/include"
|
|
42
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
diff --git a/configure b/configure
|
|
2
|
+
index e242e73..28b4bfe 100755
|
|
3
|
+
--- a/configure
|
|
4
|
+
+++ b/configure
|
|
5
|
+
@@ -606,7 +606,7 @@ if [[ $host_os = mingw* || $host_os = msys* || $host_os = cygwin* ]]; then
|
|
6
|
+
if cc_check '' -Qdiag-error:10006,10157 ; then
|
|
7
|
+
CHECK_CFLAGS="$CHECK_CFLAGS -Qdiag-error:10006,10157"
|
|
8
|
+
fi
|
|
9
|
+
- elif [[ "$cc_base" = cl || "$cc_base" = cl[\ .]* ]]; then
|
|
10
|
+
+ elif [[ "$cc_base" = cl || "$cc_base" = cl[\ .]* || "$cc_base" = clang-cl || "$cc_base" = clang-cl[\ .]* ]]; then
|
|
11
|
+
# Standard Microsoft Visual Studio
|
|
12
|
+
compiler=CL
|
|
13
|
+
compiler_style=MS
|
|
14
|
+
@@ -1458,8 +1458,8 @@ fi
|
|
15
|
+
DEPMM="${QPRE}MM"
|
|
16
|
+
DEPMT="${QPRE}MT"
|
|
17
|
+
if [ $compiler_style = MS ]; then
|
|
18
|
+
- AR="lib.exe -nologo -out:"
|
|
19
|
+
- LD="link.exe -out:"
|
|
20
|
+
+ AR="${AR-lib.exe} -nologo -out:"
|
|
21
|
+
+ LD="${LD-link.exe} -out:"
|
|
22
|
+
if [ $compiler = ICL ]; then
|
|
23
|
+
AR="xi$AR"
|
|
24
|
+
LD="xi$LD"
|
|
25
|
+
@@ -1470,7 +1470,7 @@ if [ $compiler_style = MS ]; then
|
|
26
|
+
HAVE_GETOPT_LONG=0
|
|
27
|
+
LDFLAGS="-nologo -incremental:no $(cl_ldflags $LDFLAGS)"
|
|
28
|
+
LDFLAGSCLI="$(cl_ldflags $LDFLAGSCLI)"
|
|
29
|
+
- LIBX264=libx264.lib
|
|
30
|
+
+ LIBX264=x264.lib
|
|
31
|
+
RANLIB=
|
|
32
|
+
[ -n "$RC" ] && RCFLAGS="$RCFLAGS -nologo -I. -I\$(SRCPATH)/extras -fo"
|
|
33
|
+
STRIP=
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
include_guard(GLOBAL)
|
|
2
|
+
|
|
3
|
+
if(WIN32)
|
|
4
|
+
set(lib x264.lib)
|
|
5
|
+
else()
|
|
6
|
+
set(lib libx264.a)
|
|
7
|
+
endif()
|
|
8
|
+
|
|
9
|
+
set(env)
|
|
10
|
+
|
|
11
|
+
set(args
|
|
12
|
+
--disable-cli
|
|
13
|
+
|
|
14
|
+
--enable-static
|
|
15
|
+
--enable-strip
|
|
16
|
+
--enable-pic
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
if(CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo")
|
|
20
|
+
list(APPEND args --enable-debug)
|
|
21
|
+
endif()
|
|
22
|
+
|
|
23
|
+
if(CMAKE_SYSTEM_NAME)
|
|
24
|
+
set(platform ${CMAKE_SYSTEM_NAME})
|
|
25
|
+
else()
|
|
26
|
+
set(platform ${CMAKE_HOST_SYSTEM_NAME})
|
|
27
|
+
endif()
|
|
28
|
+
|
|
29
|
+
string(TOLOWER "${platform}" platform)
|
|
30
|
+
|
|
31
|
+
if(platform MATCHES "darwin|ios")
|
|
32
|
+
set(platform "darwin")
|
|
33
|
+
elseif(platform MATCHES "linux|android")
|
|
34
|
+
set(platform "linux")
|
|
35
|
+
elseif(platform MATCHES "windows")
|
|
36
|
+
set(platform "msys")
|
|
37
|
+
else()
|
|
38
|
+
message(FATAL_ERROR "Unsupported platform '${platform}'")
|
|
39
|
+
endif()
|
|
40
|
+
|
|
41
|
+
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
|
42
|
+
set(arch ${CMAKE_OSX_ARCHITECTURES})
|
|
43
|
+
elseif(MSVC AND CMAKE_GENERATOR_PLATFORM)
|
|
44
|
+
set(arch ${CMAKE_GENERATOR_PLATFORM})
|
|
45
|
+
elseif(ANDROID AND CMAKE_ANDROID_ARCH_ABI)
|
|
46
|
+
set(arch ${CMAKE_ANDROID_ARCH_ABI})
|
|
47
|
+
elseif(CMAKE_SYSTEM_PROCESSOR)
|
|
48
|
+
set(arch ${CMAKE_SYSTEM_PROCESSOR})
|
|
49
|
+
else()
|
|
50
|
+
set(arch ${CMAKE_HOST_SYSTEM_PROCESSOR})
|
|
51
|
+
endif()
|
|
52
|
+
|
|
53
|
+
string(TOLOWER "${arch}" arch)
|
|
54
|
+
|
|
55
|
+
if(arch MATCHES "arm64|aarch64")
|
|
56
|
+
set(arch "aarch64")
|
|
57
|
+
elseif(arch MATCHES "armv7-a|armeabi-v7a")
|
|
58
|
+
set(arch "arm")
|
|
59
|
+
elseif(arch MATCHES "x64|x86_64|amd64")
|
|
60
|
+
set(arch "x86_64")
|
|
61
|
+
elseif(arch MATCHES "x86|i386|i486|i586|i686")
|
|
62
|
+
set(arch "i686")
|
|
63
|
+
else()
|
|
64
|
+
message(FATAL_ERROR "Unsupported architecture '${arch}'")
|
|
65
|
+
endif()
|
|
66
|
+
|
|
67
|
+
list(APPEND args --host=${arch}-${platform})
|
|
68
|
+
|
|
69
|
+
if(APPLE)
|
|
70
|
+
list(APPEND args --sysroot=${CMAKE_OSX_SYSROOT})
|
|
71
|
+
elseif(ANDROID)
|
|
72
|
+
list(APPEND args --sysroot=${CMAKE_SYSROOT} --disable-asm)
|
|
73
|
+
elseif(WIN32)
|
|
74
|
+
list(APPEND args --disable-asm)
|
|
75
|
+
endif()
|
|
76
|
+
|
|
77
|
+
if(CMAKE_C_COMPILER)
|
|
78
|
+
cmake_path(GET CMAKE_C_COMPILER PARENT_PATH CC_path)
|
|
79
|
+
cmake_path(GET CMAKE_C_COMPILER FILENAME CC_filename)
|
|
80
|
+
|
|
81
|
+
list(APPEND env "CC=${CC_filename}")
|
|
82
|
+
|
|
83
|
+
list(APPEND args
|
|
84
|
+
--extra-cflags=--target=${CMAKE_C_COMPILER_TARGET}
|
|
85
|
+
--extra-ldflags=--target=${CMAKE_C_COMPILER_TARGET}
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
if(CMAKE_LINKER_TYPE MATCHES "LLD")
|
|
89
|
+
list(APPEND args --extra-ldflags=-fuse-ld=lld)
|
|
90
|
+
endif()
|
|
91
|
+
|
|
92
|
+
list(APPEND env --modify "PATH=path_list_prepend:${CC_path}")
|
|
93
|
+
endif()
|
|
94
|
+
|
|
95
|
+
if(CMAKE_ASM_NASM_COMPILER)
|
|
96
|
+
cmake_path(GET CMAKE_ASM_NASM_COMPILER PARENT_PATH AS_path)
|
|
97
|
+
cmake_path(GET CMAKE_ASM_NASM_COMPILER FILENAME AS_filename)
|
|
98
|
+
|
|
99
|
+
list(APPEND env "AS=${AS_filename}")
|
|
100
|
+
|
|
101
|
+
list(APPEND env --modify "PATH=path_list_prepend:${AS_path}")
|
|
102
|
+
elseif(CMAKE_ASM_COMPILER)
|
|
103
|
+
cmake_path(GET CMAKE_ASM_COMPILER PARENT_PATH AS_path)
|
|
104
|
+
cmake_path(GET CMAKE_ASM_COMPILER FILENAME AS_filename)
|
|
105
|
+
|
|
106
|
+
list(APPEND env "AS=${AS_filename}")
|
|
107
|
+
|
|
108
|
+
list(APPEND args --extra-asflags=--target=${CMAKE_ASM_COMPILER_TARGET})
|
|
109
|
+
|
|
110
|
+
list(APPEND env --modify "PATH=path_list_prepend:${AS_path}")
|
|
111
|
+
endif()
|
|
112
|
+
|
|
113
|
+
if(CMAKE_RC_COMPILER)
|
|
114
|
+
cmake_path(GET CMAKE_RC_COMPILER PARENT_PATH RC_path)
|
|
115
|
+
cmake_path(GET CMAKE_RC_COMPILER FILENAME RC_filename)
|
|
116
|
+
|
|
117
|
+
list(APPEND env "RC=${RC_filename}")
|
|
118
|
+
|
|
119
|
+
list(APPEND env --modify "PATH=path_list_prepend:${RC_path}")
|
|
120
|
+
endif()
|
|
121
|
+
|
|
122
|
+
if(CMAKE_AR)
|
|
123
|
+
cmake_path(GET CMAKE_AR PARENT_PATH AR_path)
|
|
124
|
+
cmake_path(GET CMAKE_AR FILENAME AR_filename)
|
|
125
|
+
|
|
126
|
+
list(APPEND env "AR=${AR_filename}")
|
|
127
|
+
|
|
128
|
+
list(APPEND env --modify "PATH=path_list_prepend:${AR_path}")
|
|
129
|
+
endif()
|
|
130
|
+
|
|
131
|
+
set(patches)
|
|
132
|
+
|
|
133
|
+
if(WIN32)
|
|
134
|
+
list(APPEND patches patches/01-windows-clang.patch)
|
|
135
|
+
endif()
|
|
136
|
+
|
|
137
|
+
declare_port(
|
|
138
|
+
"git:code.videolan.org/videolan/x264#stable"
|
|
139
|
+
x264
|
|
140
|
+
AUTOTOOLS
|
|
141
|
+
BYPRODUCTS lib/${lib}
|
|
142
|
+
ARGS ${args}
|
|
143
|
+
ENV ${env}
|
|
144
|
+
PATCHES ${patches}
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
add_library(x264 STATIC IMPORTED GLOBAL)
|
|
148
|
+
|
|
149
|
+
add_dependencies(x264 ${x264})
|
|
150
|
+
|
|
151
|
+
set_target_properties(
|
|
152
|
+
x264
|
|
153
|
+
PROPERTIES
|
|
154
|
+
IMPORTED_LOCATION "${x264_PREFIX}/lib/${lib}"
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
file(MAKE_DIRECTORY "${x264_PREFIX}/include")
|
|
158
|
+
|
|
159
|
+
target_include_directories(
|
|
160
|
+
x264
|
|
161
|
+
INTERFACE "${x264_PREFIX}/include"
|
|
162
|
+
)
|
package/index.js
CHANGED
|
@@ -1,30 +1,48 @@
|
|
|
1
|
+
const AudioFIFO = require('./lib/audio-fifo')
|
|
2
|
+
const ChannelLayout = require('./lib/channel-layout')
|
|
1
3
|
const Codec = require('./lib/codec')
|
|
2
4
|
const CodecContext = require('./lib/codec-context')
|
|
3
5
|
const CodecParameters = require('./lib/codec-parameters')
|
|
4
6
|
const Decoder = require('./lib/decoder')
|
|
7
|
+
const Dictionary = require('./lib/dictionary')
|
|
5
8
|
const Encoder = require('./lib/encoder')
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const { InputFormatContext, OutputFormatContext } = require('./lib/format-context')
|
|
10
|
+
const Filter = require('./lib/filter')
|
|
11
|
+
const FilterContext = require('./lib/filter-context')
|
|
12
|
+
const FilterGraph = require('./lib/filter-graph')
|
|
13
|
+
const FilterInOut = require('./lib/filter-inout')
|
|
10
14
|
const Frame = require('./lib/frame')
|
|
11
|
-
const
|
|
15
|
+
const HWDeviceContext = require('./lib/hw-device-context')
|
|
16
|
+
const HWFramesContext = require('./lib/hw-frames-context')
|
|
17
|
+
const HWFramesConstraints = require('./lib/hw-frames-constraints')
|
|
12
18
|
const IOContext = require('./lib/io-context')
|
|
19
|
+
const Image = require('./lib/image')
|
|
13
20
|
const InputFormat = require('./lib/input-format')
|
|
14
21
|
const OutputFormat = require('./lib/output-format')
|
|
15
22
|
const Packet = require('./lib/packet')
|
|
16
|
-
const Scaler = require('./lib/scaler')
|
|
17
|
-
const Stream = require('./lib/stream')
|
|
18
23
|
const Rational = require('./lib/rational')
|
|
19
|
-
const Dictionary = require('./lib/dictionary')
|
|
20
24
|
const Resampler = require('./lib/resampler')
|
|
25
|
+
const Samples = require('./lib/samples')
|
|
26
|
+
const Scaler = require('./lib/scaler')
|
|
27
|
+
const Stream = require('./lib/stream')
|
|
28
|
+
const log = require('./lib/log')
|
|
21
29
|
|
|
30
|
+
exports.AudioFIFO = AudioFIFO
|
|
31
|
+
exports.ChannelLayout = ChannelLayout
|
|
22
32
|
exports.Codec = Codec
|
|
23
33
|
exports.CodecContext = CodecContext
|
|
24
34
|
exports.CodecParameters = CodecParameters
|
|
25
35
|
exports.Decoder = Decoder
|
|
36
|
+
exports.Dictionary = Dictionary
|
|
26
37
|
exports.Encoder = Encoder
|
|
38
|
+
exports.Filter = Filter
|
|
39
|
+
exports.FilterContext = FilterContext
|
|
40
|
+
exports.FilterGraph = FilterGraph
|
|
41
|
+
exports.FilterInOut = FilterInOut
|
|
27
42
|
exports.Frame = Frame
|
|
43
|
+
exports.HWDeviceContext = HWDeviceContext
|
|
44
|
+
exports.HWFramesContext = HWFramesContext
|
|
45
|
+
exports.HWFramesConstraints = HWFramesConstraints
|
|
28
46
|
exports.IOContext = IOContext
|
|
29
47
|
exports.Image = Image
|
|
30
48
|
exports.InputFormat = InputFormat
|
|
@@ -32,10 +50,11 @@ exports.InputFormatContext = InputFormatContext
|
|
|
32
50
|
exports.OutputFormat = OutputFormat
|
|
33
51
|
exports.OutputFormatContext = OutputFormatContext
|
|
34
52
|
exports.Packet = Packet
|
|
53
|
+
exports.Samples = Samples
|
|
35
54
|
exports.Scaler = Scaler
|
|
36
55
|
exports.Stream = Stream
|
|
37
56
|
exports.Rational = Rational
|
|
38
|
-
exports.Dictionary = Dictionary
|
|
39
57
|
exports.Resampler = Resampler
|
|
58
|
+
exports.log = log
|
|
40
59
|
|
|
41
60
|
exports.constants = require('./lib/constants')
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const binding = require('../binding')
|
|
2
|
+
const constants = require('./constants')
|
|
3
|
+
|
|
4
|
+
module.exports = class FFmpegAudioFIFO {
|
|
5
|
+
constructor(sampleFormat, channels, nbSamples) {
|
|
6
|
+
sampleFormat = constants.toSampleFormat(sampleFormat)
|
|
7
|
+
|
|
8
|
+
this._handle = binding.initAudioFifo(sampleFormat, channels, nbSamples)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
destroy() {
|
|
12
|
+
binding.destroyAudioFifo(this._handle)
|
|
13
|
+
this._handle = null
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
write(frame) {
|
|
17
|
+
return binding.writeAudioFifo(this._handle, frame._handle)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
read(frame, nbSamples) {
|
|
21
|
+
return binding.readAudioFifo(this._handle, frame._handle, nbSamples)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
peek(frame, nbSamples) {
|
|
25
|
+
return binding.peekAudioFifo(this._handle, frame._handle, nbSamples)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
drain(nbSamples) {
|
|
29
|
+
return binding.drainAudioFifo(this._handle, nbSamples)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
reset() {
|
|
33
|
+
binding.resetAudioFifo(this._handle)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get size() {
|
|
37
|
+
return binding.getAudioFifoSize(this._handle)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get space() {
|
|
41
|
+
return binding.getAudioFifoSpace(this._handle)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[Symbol.dispose]() {
|
|
45
|
+
this.destroy()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const binding = require('../binding')
|
|
2
|
+
const constants = require('./constants')
|
|
3
|
+
|
|
4
|
+
module.exports = class FFmpegChannelLayout {
|
|
5
|
+
constructor(handle) {
|
|
6
|
+
this._handle = handle
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
get nbChannels() {
|
|
10
|
+
return binding.getChannelLayoutNbChannels(this._handle)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get mask() {
|
|
14
|
+
return binding.getChannelLayoutMask(this._handle)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static from(value) {
|
|
18
|
+
if (typeof value === 'string') value = constants.toChannelLayout(value)
|
|
19
|
+
|
|
20
|
+
if (typeof value === 'number') {
|
|
21
|
+
value = binding.channelLayoutFromMask(value)
|
|
22
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
23
|
+
value = binding.copyChannelLayout(value._handle)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return new this(value)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[Symbol.for('bare.inspect')]() {
|
|
30
|
+
return {
|
|
31
|
+
__proto__: { constructor: FFmpegChannelLayout },
|
|
32
|
+
nbChannels: this.nbChannels
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
package/lib/codec-context.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const binding = require('../binding')
|
|
2
2
|
const Rational = require('./rational')
|
|
3
|
+
const ChannelLayout = require('./channel-layout')
|
|
4
|
+
const HWDeviceContext = require('./hw-device-context')
|
|
5
|
+
const { codecConfig, optionFlags } = require('./constants')
|
|
3
6
|
|
|
4
7
|
module.exports = class FFmpegCodecContext {
|
|
5
8
|
constructor(codec) {
|
|
@@ -37,17 +40,101 @@ module.exports = class FFmpegCodecContext {
|
|
|
37
40
|
binding.setCodecContextHeight(this._handle, value)
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
get sampleFormat() {
|
|
44
|
+
return binding.getCodecContextSampleFormat(this._handle)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
set sampleFormat(value) {
|
|
48
|
+
return binding.setCodecContextSampleFormat(this._handle, value)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get sampleRate() {
|
|
52
|
+
return binding.getCodecContextSampleRate(this._handle)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
set sampleRate(value) {
|
|
56
|
+
binding.setCodecContextSampleRate(this._handle, value)
|
|
57
|
+
}
|
|
58
|
+
|
|
40
59
|
get timeBase() {
|
|
41
60
|
const view = new Int32Array(binding.getCodecContextTimeBase(this._handle))
|
|
42
61
|
return new Rational(view[0], view[1])
|
|
43
62
|
}
|
|
44
63
|
|
|
45
64
|
set timeBase(value) {
|
|
46
|
-
binding.setCodecContextTimeBase(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
65
|
+
binding.setCodecContextTimeBase(this._handle, value.numerator, value.denominator)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get frameRate() {
|
|
69
|
+
const view = new Int32Array(binding.getCodecContextFramerate(this._handle))
|
|
70
|
+
return new Rational(view[0], view[1])
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
set frameRate(value) {
|
|
74
|
+
binding.setCodecContextFramerate(this._handle, value.numerator, value.denominator)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get channelLayout() {
|
|
78
|
+
return new ChannelLayout(binding.getCodecContextChannelLayout(this._handle))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
set channelLayout(value) {
|
|
82
|
+
binding.setCodecContextChannelLayout(this._handle, ChannelLayout.from(value)._handle)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get gopSize() {
|
|
86
|
+
return binding.getCodecContextGOPSize(this._handle)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
set gopSize(value) {
|
|
90
|
+
binding.setCodecContextGOPSize(this._handle, value)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
get flags() {
|
|
94
|
+
return binding.getCodecContextFlags(this._handle)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
set flags(value) {
|
|
98
|
+
binding.setCodecContextFlags(this._handle, value)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
get extraData() {
|
|
102
|
+
return Buffer.from(binding.getCodecContextExtraData(this._handle))
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
set extraData(value) {
|
|
106
|
+
binding.setCodecContextExtraData(this._handle, value.buffer, value.byteOffset, value.byteLength)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get frameSize() {
|
|
110
|
+
return binding.getCodecContextFrameSize(this._handle)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get frameNum() {
|
|
114
|
+
return binding.getCodecContextFrameNum(this._handle)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get requestSampleFormat() {
|
|
118
|
+
return binding.getCodecContextRequestSampleFormat(this._handle)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
set requestSampleFormat(sampleFormat) {
|
|
122
|
+
binding.setCodecContextRequestSampleFormat(this._handle, sampleFormat)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
get hwDeviceCtx() {
|
|
126
|
+
return HWDeviceContext.from(binding.getCodecContextHWDeviceCtx(this._handle))
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
set hwDeviceCtx(hwDeviceContext) {
|
|
130
|
+
binding.setCodecContextHWDeviceCtx(this._handle, hwDeviceContext._handle)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
set getFormat(callback) {
|
|
134
|
+
const wrap = (pixelFormats) => {
|
|
135
|
+
return callback(this, pixelFormats)
|
|
136
|
+
}
|
|
137
|
+
binding.setCodecContextGetFormat(this._handle, wrap)
|
|
51
138
|
}
|
|
52
139
|
|
|
53
140
|
open(options) {
|
|
@@ -58,7 +145,6 @@ module.exports = class FFmpegCodecContext {
|
|
|
58
145
|
} else {
|
|
59
146
|
binding.openCodecContext(this._handle)
|
|
60
147
|
}
|
|
61
|
-
return this
|
|
62
148
|
}
|
|
63
149
|
|
|
64
150
|
sendPacket(packet) {
|
|
@@ -70,14 +156,106 @@ module.exports = class FFmpegCodecContext {
|
|
|
70
156
|
}
|
|
71
157
|
|
|
72
158
|
sendFrame(frame) {
|
|
73
|
-
|
|
159
|
+
let frameHandle = undefined
|
|
160
|
+
|
|
161
|
+
if (frame) frameHandle = frame._handle
|
|
162
|
+
|
|
163
|
+
return binding.sendCodecContextFrame(this._handle, frameHandle)
|
|
74
164
|
}
|
|
75
165
|
|
|
76
166
|
receiveFrame(frame) {
|
|
77
167
|
return binding.receiveCodecContextFrame(this._handle, frame._handle)
|
|
78
168
|
}
|
|
79
169
|
|
|
170
|
+
getSupportedConfig(config) {
|
|
171
|
+
if (config === codecConfig.FRAME_RATE) {
|
|
172
|
+
const data = binding.getSupportedFrameRates(this._handle, this._codec._handle)
|
|
173
|
+
if (!data || data.length === 0) return null
|
|
174
|
+
|
|
175
|
+
const view = new Int32Array(data)
|
|
176
|
+
const rates = []
|
|
177
|
+
for (let i = 0; i < view.length; i += 2) {
|
|
178
|
+
rates.push(new Rational(view[i], view[i + 1]))
|
|
179
|
+
}
|
|
180
|
+
return rates
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (config === codecConfig.CHANNEL_LAYOUT) {
|
|
184
|
+
const handles = binding.getSupportedChannelLayouts(this._handle, this._codec._handle)
|
|
185
|
+
if (!handles || handles.length === 0) return null
|
|
186
|
+
|
|
187
|
+
return handles.map((handle) => new ChannelLayout(handle))
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const data = binding.getSupportedConfig(this._handle, this._codec._handle, config)
|
|
191
|
+
|
|
192
|
+
if (config === codecConfig.SAMPLE_RATE && !data) {
|
|
193
|
+
return null
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return new Int32Array(data)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
getOption(name, flags = optionFlags.SEARCH_CHILDREN) {
|
|
200
|
+
return binding.getOption(this._handle, name, flags)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
setOption(name, value, flags = optionFlags.SEARCH_CHILDREN) {
|
|
204
|
+
return binding.setOption(this._handle, name, value, flags)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
setOptionDictionary(dictionary, flags = optionFlags.SEARCH_CHILDREN) {
|
|
208
|
+
return binding.setOptionDictionary(this._handle, dictionary._handle, flags)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
setOptionDefaults() {
|
|
212
|
+
return binding.setOptionDefaults(this._handle)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
listOptionNames(flags = optionFlags.SEARCH_CHILDREN) {
|
|
216
|
+
return binding.listOptionNames(this._handle, flags)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
getOptions(flags) {
|
|
220
|
+
const options = {}
|
|
221
|
+
|
|
222
|
+
for (const name of this.listOptionNames(flags)) {
|
|
223
|
+
try {
|
|
224
|
+
options[name] = this.getOption(name, flags)
|
|
225
|
+
} catch (error) {
|
|
226
|
+
// TODO: handle binary and other non-string types
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return options
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
copyOptionsFrom(codecContext) {
|
|
234
|
+
binding.copyOptions(this._handle, codecContext._handle)
|
|
235
|
+
}
|
|
236
|
+
|
|
80
237
|
[Symbol.dispose]() {
|
|
81
238
|
this.destroy()
|
|
82
239
|
}
|
|
240
|
+
|
|
241
|
+
[Symbol.for('bare.inspect')]() {
|
|
242
|
+
return {
|
|
243
|
+
__proto__: { constructor: FFmpegCodecContext },
|
|
244
|
+
_codec: this._codec,
|
|
245
|
+
_opened: this._opened,
|
|
246
|
+
flags: this.flags,
|
|
247
|
+
pixelFormat: this.pixelFormat,
|
|
248
|
+
width: this.width,
|
|
249
|
+
height: this.height,
|
|
250
|
+
sampleFormat: this.sampleFormat,
|
|
251
|
+
sampleRate: this.sampleRate,
|
|
252
|
+
timeBase: this.timeBase,
|
|
253
|
+
channelLayout: this.channelLayout,
|
|
254
|
+
gopSize: this.gopSize,
|
|
255
|
+
extraData: this.extraData,
|
|
256
|
+
frameRate: this.frameRate,
|
|
257
|
+
frameSize: this.frameSize,
|
|
258
|
+
frameNum: this.frameNum
|
|
259
|
+
}
|
|
260
|
+
}
|
|
83
261
|
}
|