@lumen5/beamcoder 0.0.1
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/.circleci/config.yml +41 -0
- package/.circleci/images/testbeam10-4.1/Dockerfile +12 -0
- package/.circleci/test_image/Dockerfile +14 -0
- package/.circleci/test_image/build.md +13 -0
- package/.eslintrc.js +27 -0
- package/.github/workflows/publish-npm.yml +33 -0
- package/LICENSE +674 -0
- package/README.md +1221 -0
- package/beamstreams.js +692 -0
- package/binding.gyp +103 -0
- package/examples/encode_h264.js +92 -0
- package/examples/jpeg_app.js +55 -0
- package/examples/jpeg_filter_app.js +101 -0
- package/examples/make_mp4.js +123 -0
- package/images/beamcoder_small.jpg +0 -0
- package/index.d.ts +83 -0
- package/index.js +44 -0
- package/install_ffmpeg.js +240 -0
- package/package.json +45 -0
- package/scratch/decode_aac.js +38 -0
- package/scratch/decode_avci.js +50 -0
- package/scratch/decode_hevc.js +38 -0
- package/scratch/decode_pcm.js +39 -0
- package/scratch/make_a_mux.js +68 -0
- package/scratch/muxer.js +74 -0
- package/scratch/read_wav.js +35 -0
- package/scratch/simple_mux.js +39 -0
- package/scratch/stream_avci.js +127 -0
- package/scratch/stream_mp4.js +78 -0
- package/scratch/stream_mux.js +47 -0
- package/scratch/stream_pcm.js +82 -0
- package/scratch/stream_wav.js +62 -0
- package/scripts/install_beamcoder_dependencies.sh +25 -0
- package/src/adaptor.h +202 -0
- package/src/beamcoder.cc +937 -0
- package/src/beamcoder_util.cc +1129 -0
- package/src/beamcoder_util.h +206 -0
- package/src/codec.cc +7386 -0
- package/src/codec.h +44 -0
- package/src/codec_par.cc +1818 -0
- package/src/codec_par.h +40 -0
- package/src/decode.cc +569 -0
- package/src/decode.h +75 -0
- package/src/demux.cc +584 -0
- package/src/demux.h +88 -0
- package/src/encode.cc +496 -0
- package/src/encode.h +72 -0
- package/src/filter.cc +1888 -0
- package/src/filter.h +30 -0
- package/src/format.cc +5287 -0
- package/src/format.h +77 -0
- package/src/frame.cc +2681 -0
- package/src/frame.h +52 -0
- package/src/governor.cc +286 -0
- package/src/governor.h +30 -0
- package/src/hwcontext.cc +378 -0
- package/src/hwcontext.h +35 -0
- package/src/log.cc +186 -0
- package/src/log.h +20 -0
- package/src/mux.cc +834 -0
- package/src/mux.h +106 -0
- package/src/packet.cc +762 -0
- package/src/packet.h +49 -0
- package/test/codecParamsSpec.js +148 -0
- package/test/decoderSpec.js +56 -0
- package/test/demuxerSpec.js +41 -0
- package/test/encoderSpec.js +69 -0
- package/test/filtererSpec.js +47 -0
- package/test/formatSpec.js +343 -0
- package/test/frameSpec.js +145 -0
- package/test/introspectionSpec.js +73 -0
- package/test/muxerSpec.js +34 -0
- package/test/packetSpec.js +122 -0
- package/types/Beamstreams.d.ts +98 -0
- package/types/Codec.d.ts +123 -0
- package/types/CodecContext.d.ts +555 -0
- package/types/CodecPar.d.ts +108 -0
- package/types/Decoder.d.ts +137 -0
- package/types/Demuxer.d.ts +113 -0
- package/types/Encoder.d.ts +94 -0
- package/types/Filter.d.ts +324 -0
- package/types/FormatContext.d.ts +380 -0
- package/types/Frame.d.ts +295 -0
- package/types/HWContext.d.ts +62 -0
- package/types/Muxer.d.ts +121 -0
- package/types/Packet.d.ts +82 -0
- package/types/PrivClass.d.ts +25 -0
- package/types/Stream.d.ts +165 -0
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
import { HWDeviceContext, HWFramesContext } from "./HWContext"
|
|
2
|
+
|
|
3
|
+
export type MotionEstimationString = 'sad' | 'sse' | 'satd' | 'dct' | 'psnr' | 'bit' | 'rd' | 'zero' | 'vsad' |
|
|
4
|
+
'vsse' | 'nsse' | 'w53' | 'w97' | 'dctmax' | 'dct264' | 'median_sad' | 'chroma'
|
|
5
|
+
export type FrameSkipString = 'none' | 'default' | 'nonref' | 'bidir' | 'nonintra' | 'nonkey' | 'all'
|
|
6
|
+
|
|
7
|
+
/** The CodecContext object */
|
|
8
|
+
export interface CodecContext {
|
|
9
|
+
/** Object name. */
|
|
10
|
+
readonly type: string
|
|
11
|
+
/** see AV_CODEC_ID_xxx */
|
|
12
|
+
readonly codec_id: number
|
|
13
|
+
/**
|
|
14
|
+
* Name of the codec implementation.
|
|
15
|
+
* The name is globally unique among encoders and among decoders (but an
|
|
16
|
+
* encoder and a decoder can share the same name).
|
|
17
|
+
* This is the primary way to find a codec from the user perspective.
|
|
18
|
+
*/
|
|
19
|
+
readonly name: string
|
|
20
|
+
/** Descriptive name for the codec, meant to be more human readable than name. */
|
|
21
|
+
readonly long_name: string
|
|
22
|
+
/**
|
|
23
|
+
* A fourcc string by default, will be a number if not recognised
|
|
24
|
+
* - LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
|
|
25
|
+
*/
|
|
26
|
+
readonly codec_tag: string | number
|
|
27
|
+
/** Codec private data. */
|
|
28
|
+
priv_data: { [key: string]: any } | null
|
|
29
|
+
/** The average bitrate */
|
|
30
|
+
bit_rate: number
|
|
31
|
+
/**
|
|
32
|
+
* Number of bits the bitstream is allowed to diverge from the reference.
|
|
33
|
+
* The reference can be CBR (for CBR pass1) or VBR (for pass2)
|
|
34
|
+
*/
|
|
35
|
+
bit_rate_tolerance: number
|
|
36
|
+
/** Global quality for codecs which cannot change it per frame. This should be proportional to MPEG-1/2/4 qscale. */
|
|
37
|
+
global_quality: number
|
|
38
|
+
compression_level: number
|
|
39
|
+
/** AV_CODEC_FLAG_*. */
|
|
40
|
+
flags: { [key: string]: boolean }
|
|
41
|
+
/** AV_CODEC_FLAG2_*. */
|
|
42
|
+
flags2: { [key: string]: boolean }
|
|
43
|
+
/**
|
|
44
|
+
* some codecs need / can use extradata like Huffman tables.
|
|
45
|
+
* MJPEG: Huffman tables
|
|
46
|
+
* rv10: additional flags
|
|
47
|
+
* MPEG-4: global headers (they can be in the bitstream or here)
|
|
48
|
+
* The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
|
|
49
|
+
* than extradata_size to avoid problems if it is read with the bitstream reader.
|
|
50
|
+
* The bytewise contents of extradata must not depend on the architecture or CPU endianness.
|
|
51
|
+
*/
|
|
52
|
+
extradata: Buffer | null
|
|
53
|
+
/**
|
|
54
|
+
* This is the fundamental unit of time (in seconds) in terms
|
|
55
|
+
* of which frame timestamps are represented. For fixed-fps content,
|
|
56
|
+
* timebase should be 1/framerate and timestamp increments should be
|
|
57
|
+
* identically 1.
|
|
58
|
+
* This often, but not always is the inverse of the frame rate or field rate
|
|
59
|
+
* for video. 1/time_base is not the average frame rate if the frame rate is not
|
|
60
|
+
* constant.
|
|
61
|
+
*
|
|
62
|
+
* Like containers, elementary streams also can store timestamps, 1/time_base
|
|
63
|
+
* is the unit in which these timestamps are specified.
|
|
64
|
+
* As example of such codec time base see ISO/IEC 14496-2:2001(E)
|
|
65
|
+
* vop_time_increment_resolution and fixed_vop_rate
|
|
66
|
+
* (fixed_vop_rate == 0 implies that it is different from the framerate)
|
|
67
|
+
*/
|
|
68
|
+
time_base: Array<number>
|
|
69
|
+
/**
|
|
70
|
+
* For some codecs, the time base is closer to the field rate than the frame rate.
|
|
71
|
+
* Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
|
|
72
|
+
* if no telecine is used ...
|
|
73
|
+
*
|
|
74
|
+
* Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
|
|
75
|
+
*/
|
|
76
|
+
ticks_per_frame: number
|
|
77
|
+
/**
|
|
78
|
+
* Number of frames delay in addition to what a standard decoder
|
|
79
|
+
* as specified in the spec would produce.
|
|
80
|
+
*
|
|
81
|
+
* Video:
|
|
82
|
+
* Number of frames the decoded output will be delayed relative to the
|
|
83
|
+
* encoded input.
|
|
84
|
+
*
|
|
85
|
+
* Audio:
|
|
86
|
+
* Number of samples the decoder needs to output before the decoder's output is valid.
|
|
87
|
+
* When seeking, you should start decoding this many samples prior to your desired seek point.
|
|
88
|
+
*/
|
|
89
|
+
readonly delay: number
|
|
90
|
+
/**
|
|
91
|
+
* picture width / height.
|
|
92
|
+
*
|
|
93
|
+
* @note Those fields may not match the values of the last
|
|
94
|
+
* Frame output due to frame reordering.
|
|
95
|
+
*
|
|
96
|
+
* May be set by the user before opening the decoder if known e.g.
|
|
97
|
+
* from the container. Some decoders will require the dimensions
|
|
98
|
+
* to be set by the caller. During decoding, the decoder may
|
|
99
|
+
* overwrite those values as required while parsing the data.
|
|
100
|
+
*/
|
|
101
|
+
width: number
|
|
102
|
+
height: number
|
|
103
|
+
/**
|
|
104
|
+
* Bitstream width / height, may be different from width/height e.g. when
|
|
105
|
+
* the decoded frame is cropped before being output or lowres is enabled.
|
|
106
|
+
*
|
|
107
|
+
* @note Those field may not match the value of the last
|
|
108
|
+
* Frame output due to frame reordering.
|
|
109
|
+
*
|
|
110
|
+
* May be set by the user before opening the decoder if known
|
|
111
|
+
* e.g. from the container. During decoding, the decoder may
|
|
112
|
+
* overwrite those values as required while parsing the data.
|
|
113
|
+
*/
|
|
114
|
+
coded_width: any
|
|
115
|
+
coded_height: any
|
|
116
|
+
/**
|
|
117
|
+
* Pixel format, see AV_PIX_FMT_xxx.
|
|
118
|
+
* May be set by the demuxer if known from headers.
|
|
119
|
+
* May be overridden by the decoder if it knows better.
|
|
120
|
+
*
|
|
121
|
+
* @note This field may not match the value of the last
|
|
122
|
+
* Frame output due to frame reordering.
|
|
123
|
+
*/
|
|
124
|
+
pix_fmt: string | null
|
|
125
|
+
/**
|
|
126
|
+
* Maximum number of B-frames between non-B-frames
|
|
127
|
+
* Note: The output will be delayed by max_b_frames+1 relative to the input.
|
|
128
|
+
*/
|
|
129
|
+
max_b_frames: number
|
|
130
|
+
/** qscale factor between IP and B-frames
|
|
131
|
+
* If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
|
|
132
|
+
* If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
|
|
133
|
+
*/
|
|
134
|
+
b_quant_factor: number
|
|
135
|
+
/** qscale offset between IP and B-frames */
|
|
136
|
+
b_quant_offset: number
|
|
137
|
+
/**
|
|
138
|
+
* Size of the frame reordering buffer in the decoder.
|
|
139
|
+
* For MPEG-2 it is 1 IPB or 0 low delay IP.
|
|
140
|
+
*/
|
|
141
|
+
readonly has_b_frames: number
|
|
142
|
+
/** qscale factor between P- and I-frames
|
|
143
|
+
* If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset).
|
|
144
|
+
* If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
|
|
145
|
+
*/
|
|
146
|
+
i_quant_factor: number
|
|
147
|
+
/** qscale offset between P and I-frames */
|
|
148
|
+
i_quant_offset: number
|
|
149
|
+
/** luminance masking (0-> disabled) */
|
|
150
|
+
lumi_masking: number
|
|
151
|
+
/** temporal complexity masking (0-> disabled) */
|
|
152
|
+
temporal_cplx_masking: number
|
|
153
|
+
/** spatial complexity masking (0-> disabled) */
|
|
154
|
+
spatial_cplx_masking: number
|
|
155
|
+
/** p block masking (0-> disabled) */
|
|
156
|
+
p_masking: number
|
|
157
|
+
/** darkness masking (0-> disabled) */
|
|
158
|
+
dark_masking: number
|
|
159
|
+
/** slice count */
|
|
160
|
+
slice_count: number
|
|
161
|
+
/** slice offsets in the frame in bytes */
|
|
162
|
+
slice_offset: Array<number> | null
|
|
163
|
+
/**
|
|
164
|
+
* sample aspect ratio (0/1 if unknown)
|
|
165
|
+
* That is the width of a pixel divided by the height of the pixel.
|
|
166
|
+
* Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
|
|
167
|
+
*/
|
|
168
|
+
sample_aspect_ratio: Array<number>
|
|
169
|
+
/** motion estimation comparison function */
|
|
170
|
+
me_cmp: MotionEstimationString
|
|
171
|
+
/** subpixel motion estimation comparison function */
|
|
172
|
+
me_sub_cmp: MotionEstimationString
|
|
173
|
+
/** macroblock comparison function (not supported yet) */
|
|
174
|
+
mb_cmp: MotionEstimationString
|
|
175
|
+
/** interlaced DCT comparison function */
|
|
176
|
+
ildct_cmp: MotionEstimationString
|
|
177
|
+
/** ME diamond size & shape */
|
|
178
|
+
dia_size: number
|
|
179
|
+
/** amount of previous MV predictors (2a+1 x 2a+1 square) */
|
|
180
|
+
last_predictor_count: number
|
|
181
|
+
/** motion estimation prepass comparison function */
|
|
182
|
+
me_pre_cmp: MotionEstimationString
|
|
183
|
+
/** ME prepass diamond size & shape */
|
|
184
|
+
pre_dia_size: number
|
|
185
|
+
/** subpel ME quality */
|
|
186
|
+
me_subpel_quality: number
|
|
187
|
+
/** maximum motion estimation search range in subpel units. If 0 then no limit. */
|
|
188
|
+
me_range: number
|
|
189
|
+
slice_flags: {
|
|
190
|
+
/** draw_horiz_band() is called in coded order instead of display */
|
|
191
|
+
CODED_ORDER: boolean
|
|
192
|
+
/** allow draw_horiz_band() with field slices (MPEG-2 field pics) */
|
|
193
|
+
ALLOW_FIELD: boolean
|
|
194
|
+
/** allow draw_horiz_band() with 1 component at a time (SVQ1) */
|
|
195
|
+
ALLOW_PLANE: boolean
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* macroblock decision mode
|
|
199
|
+
* simple: uses mb_cmp
|
|
200
|
+
* bits: chooses the one which needs the fewest bits
|
|
201
|
+
* rd: rate distortion
|
|
202
|
+
*/
|
|
203
|
+
mb_decision: 'simple' | 'bits' | 'rd'
|
|
204
|
+
/** custom intra quantization matrix */
|
|
205
|
+
intra_matrix: Array<number> | null
|
|
206
|
+
/** custom inter quantization matrix */
|
|
207
|
+
inter_matrix: Array<number> | null
|
|
208
|
+
/** precision of the intra DC coefficient - 8 */
|
|
209
|
+
intra_dc_precision: number
|
|
210
|
+
/** Number of macroblock rows at the top which are skipped. */
|
|
211
|
+
skip_top: number
|
|
212
|
+
/** Number of macroblock rows at the bottom which are skipped. */
|
|
213
|
+
skip_bottom: number
|
|
214
|
+
/** minimum MB Lagrange multiplier */
|
|
215
|
+
mb_lmin: number
|
|
216
|
+
/** maximum MB Lagrange multiplier */
|
|
217
|
+
mb_lmax: number
|
|
218
|
+
/** */
|
|
219
|
+
bidir_refine: number
|
|
220
|
+
/** minimum GOP size */
|
|
221
|
+
keyint_min: number
|
|
222
|
+
/** number of reference frames */
|
|
223
|
+
refs: number
|
|
224
|
+
/** Value depends upon the compare function used for fullpel ME. */
|
|
225
|
+
mv0_threshold: number
|
|
226
|
+
/** Chromaticity coordinates of the source primaries. */
|
|
227
|
+
color_primaries?: string
|
|
228
|
+
/** Color Transfer Characteristic. */
|
|
229
|
+
color_trc: string
|
|
230
|
+
/** YUV colorspace type. */
|
|
231
|
+
colorspace: string
|
|
232
|
+
/** MPEG vs JPEG YUV range. */
|
|
233
|
+
color_range: string
|
|
234
|
+
/**
|
|
235
|
+
* Location of chroma samples.
|
|
236
|
+
*
|
|
237
|
+
* Illustration showing the location of the first (top left) chroma sample of the
|
|
238
|
+
* image, the left shows only luma, the right
|
|
239
|
+
* shows the location of the chroma sample, the 2 could be imagined to overlay
|
|
240
|
+
* each other but are drawn separately due to limitations of ASCII
|
|
241
|
+
*```
|
|
242
|
+
* 1st 2nd 1st 2nd horizontal luma sample positions
|
|
243
|
+
* v v v v
|
|
244
|
+
* ______ ______
|
|
245
|
+
*1st luma line > |X X ... |3 4 X ... X are luma samples,
|
|
246
|
+
*. | |1 2 1-6 are possible chroma positions
|
|
247
|
+
*2nd luma line > |X X ... |5 6 X ... 0 is undefined/unknown position
|
|
248
|
+
*```
|
|
249
|
+
*/
|
|
250
|
+
chroma_sample_location: 'unspecified' | 'left' | 'center' | 'topleft' | 'top' | 'bottomleft' | 'bottom'
|
|
251
|
+
/** Number of slices. Indicates number of picture subdivisions. Used for parallelized decoding. */
|
|
252
|
+
slices: number
|
|
253
|
+
field_order: 'progressive' |
|
|
254
|
+
'top coded first, top displayed first' |
|
|
255
|
+
'bottom coded first, bottom displayed first' |
|
|
256
|
+
'top coded first, bottom displayed first' |
|
|
257
|
+
'bottom coded first, top displayed first' |
|
|
258
|
+
'unknown'
|
|
259
|
+
/** Audio only - samples per second */
|
|
260
|
+
sample_rate: number
|
|
261
|
+
/** Audio only - number of audio channels */
|
|
262
|
+
channels: number
|
|
263
|
+
/** audio sample format */
|
|
264
|
+
sample_fmt: string | null
|
|
265
|
+
/**
|
|
266
|
+
* Number of samples per channel in an audio frame.
|
|
267
|
+
* May be set by some decoders to indicate constant frame size
|
|
268
|
+
*/
|
|
269
|
+
readonly frame_size: number
|
|
270
|
+
/**
|
|
271
|
+
* Frame counter - total number of frames returned from the decoder so far.
|
|
272
|
+
* @note the counter is not incremented if encoding/decoding resulted in an error.
|
|
273
|
+
*/
|
|
274
|
+
readonly frame_number: number
|
|
275
|
+
/** number of bytes per packet if constant and known or 0. Used by some WAV based audio codecs. */
|
|
276
|
+
block_align: number
|
|
277
|
+
/** Audio cutoff bandwidth (0 means "automatic") */
|
|
278
|
+
cutoff: number
|
|
279
|
+
/** Audio channel layout. */
|
|
280
|
+
channel_layout: string
|
|
281
|
+
/** Request decoder to use this channel layout if it can (0 for default) */
|
|
282
|
+
request_channel_layout: string
|
|
283
|
+
/** Type of service that the audio stream conveys. */
|
|
284
|
+
audio_service_type: 'main' | 'effects' | 'visually-impaired' | 'hearing-impaired' | 'dialogue' |
|
|
285
|
+
'commentary' | 'emergency' | 'voice-over' | 'karaoke' | 'nb'
|
|
286
|
+
/** Desired sample format - decoder will decode to this format if it can. */
|
|
287
|
+
request_sample_fmt: string | null
|
|
288
|
+
/** amount of qscale change between easy & hard scenes (0.0-1.0) */
|
|
289
|
+
qcompress: number
|
|
290
|
+
/** amount of qscale smoothing over time (0.0-1.0) */
|
|
291
|
+
qblur: number
|
|
292
|
+
/** minimum quantizer */
|
|
293
|
+
qmin: number
|
|
294
|
+
/** maximum quantizer */
|
|
295
|
+
qmax: number
|
|
296
|
+
/** maximum quantizer difference between frames */
|
|
297
|
+
max_qdiff: number
|
|
298
|
+
/** decoder bitstream buffer size */
|
|
299
|
+
rc_buffer_size: number
|
|
300
|
+
/** ratecontrol override */
|
|
301
|
+
rc_override: Array<{
|
|
302
|
+
type: 'RcOverride'
|
|
303
|
+
start_frame: number
|
|
304
|
+
end_frame: number
|
|
305
|
+
/** If this is 0 then quality_factor will be used instead. */
|
|
306
|
+
qscale: number
|
|
307
|
+
quality_factor: number
|
|
308
|
+
}>
|
|
309
|
+
/** maximum bitrate */
|
|
310
|
+
rc_max_rate: number
|
|
311
|
+
/** minimum bitrate */
|
|
312
|
+
rc_min_rate: number
|
|
313
|
+
/** Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow. */
|
|
314
|
+
rc_max_available_vbv_use: number
|
|
315
|
+
/** Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow. */
|
|
316
|
+
rc_min_vbv_overflow_use: number
|
|
317
|
+
/** Number of bits which should be loaded into the rc buffer before decoding starts. */
|
|
318
|
+
rc_initial_buffer_occupancy: number
|
|
319
|
+
/** trellis RD quantization */
|
|
320
|
+
trellis: number
|
|
321
|
+
/** pass1 encoding statistics output buffer */
|
|
322
|
+
readonly stats_out: string | null
|
|
323
|
+
/** pass2 encoding statistics input buffer. Concatenated stuff from stats_out of pass1 should be placed here. */
|
|
324
|
+
stats_in: string | null
|
|
325
|
+
/** Work around bugs in codecs which sometimes cannot be detected automatically. */
|
|
326
|
+
workaround_bugs: { [key: string]: boolean }
|
|
327
|
+
/**
|
|
328
|
+
* strictly follow the standard (MPEG-4, ...).
|
|
329
|
+
* Setting this to STRICT or higher means the encoder and decoder will
|
|
330
|
+
* generally do stupid things, whereas setting it to unofficial or lower
|
|
331
|
+
* will mean the encoder might produce output that is not supported by all
|
|
332
|
+
* spec-compliant decoders. Decoders don't differentiate between normal,
|
|
333
|
+
* unofficial and experimental (that is, they always try to decode things
|
|
334
|
+
* when they can) unless they are explicitly asked to behave stupidly
|
|
335
|
+
* (=strictly conform to the specs)
|
|
336
|
+
*/
|
|
337
|
+
strict_std_compliance: 'very-strict' | 'strict' | 'normal' | 'unofficial' | 'experimental'
|
|
338
|
+
/** Error concealment flags */
|
|
339
|
+
error_concealment: {
|
|
340
|
+
GUESS_MVS?: boolean
|
|
341
|
+
DEBLOCK?: boolean
|
|
342
|
+
FAVOR_INTER?: boolean
|
|
343
|
+
}
|
|
344
|
+
debug: { [key: string]: boolean }
|
|
345
|
+
/** Error recognition - may misdetect some more or less valid parts as errors. */
|
|
346
|
+
err_recognition: { [key: string]: boolean }
|
|
347
|
+
/** Opaque 64-bit number (generally a PTS) that will be reordered and output in Frame.reordered_opaque */
|
|
348
|
+
reordered_opaque: number
|
|
349
|
+
readonly error: ReadonlyArray<number> | null
|
|
350
|
+
/** DCT algorithm */
|
|
351
|
+
dct_algo: 'auto' | 'fastint' | 'int' | 'mmx' | 'altivec' | 'faan'
|
|
352
|
+
/** IDCT algorithm */
|
|
353
|
+
idct_algo: 'auto' | 'int' | 'simple' | 'simplemmx' | 'arm' | 'altivec' | 'simplearm' | 'xvid' | 'simplearmv5te' | 'simplearmv6' | 'faan' | 'simpleneon' | 'none' | 'simpleauto'
|
|
354
|
+
/** Bits per sample/pixel from the demuxer (needed for huffyuv). */
|
|
355
|
+
bits_per_coded_sample: number
|
|
356
|
+
/** Bits per sample/pixel of internal libavcodec pixel/sample format. */
|
|
357
|
+
bits_per_raw_sample: number
|
|
358
|
+
/** Thread count is used to decide how many independent tasks should be passed to execute() */
|
|
359
|
+
thread_count: number
|
|
360
|
+
/**
|
|
361
|
+
* Which multithreading methods to use.
|
|
362
|
+
* Use of FRAME will increase decoding delay by one frame per thread,
|
|
363
|
+
* so clients which cannot provide future frames should not use it.
|
|
364
|
+
*/
|
|
365
|
+
thread_type: { FRAME?: boolean, SLICE?: boolean }
|
|
366
|
+
/** Which multithreading methods are in use by the codec. */
|
|
367
|
+
readonly active_thread_type: { FRAME?: boolean, SLICE?: boolean }
|
|
368
|
+
/**
|
|
369
|
+
* Set by the client if its custom get_buffer() callback can be called
|
|
370
|
+
* synchronously from another thread, which allows faster multithreaded decoding.
|
|
371
|
+
* draw_horiz_band() will be called from other threads regardless of this setting.
|
|
372
|
+
* Ignored if the default get_buffer() is used.
|
|
373
|
+
*/
|
|
374
|
+
thread_safe_callbacks: number
|
|
375
|
+
/** nsse_weight */
|
|
376
|
+
nsse_weight: number
|
|
377
|
+
|
|
378
|
+
profile: string | number
|
|
379
|
+
level: number
|
|
380
|
+
/** Skip loop filtering for selected frames. */
|
|
381
|
+
skip_loop_filter: FrameSkipString
|
|
382
|
+
/** Skip IDCT/dequantization for selected frames. */
|
|
383
|
+
skip_idct: FrameSkipString
|
|
384
|
+
/** Skip decoding for selected frames. */
|
|
385
|
+
skip_frame: FrameSkipString
|
|
386
|
+
/**
|
|
387
|
+
* Header containing style information for text subtitles.
|
|
388
|
+
* For SUBTITLE_ASS subtitle type, it should contain the whole ASS
|
|
389
|
+
* [Script Info] and [V4+ Styles] section, plus the [Events] line and
|
|
390
|
+
* the Format line following. It shouldn't include any Dialogue line.
|
|
391
|
+
*/
|
|
392
|
+
subtitle_header: Buffer | null
|
|
393
|
+
/**
|
|
394
|
+
* Audio only. The number of "priming" samples (padding) inserted by the
|
|
395
|
+
* encoder at the beginning of the audio. I.e. this number of leading
|
|
396
|
+
* decoded samples must be discarded by the caller to get the original audio
|
|
397
|
+
* without leading padding.
|
|
398
|
+
*
|
|
399
|
+
* The timestamps on the output packets are adjusted by the encoder so that
|
|
400
|
+
* they always refer to the first sample of the data actually contained in the packet,
|
|
401
|
+
* including any added padding. E.g. if the timebase is 1/samplerate and
|
|
402
|
+
* the timestamp of the first input sample is 0, the timestamp of the
|
|
403
|
+
* first output packet will be -initial_padding.
|
|
404
|
+
*/
|
|
405
|
+
readonly inital_padding: number
|
|
406
|
+
/**
|
|
407
|
+
* For codecs that store a framerate value in the compressed
|
|
408
|
+
* bitstream, the decoder may export it here. [ 0, 1 ] when unknown.
|
|
409
|
+
*/
|
|
410
|
+
framerate: Array<number>
|
|
411
|
+
/** Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx. */
|
|
412
|
+
readonly sw_pix_fmt: string | null
|
|
413
|
+
/** Timebase in which pkt_dts/pts and Packet dts/pts are. */
|
|
414
|
+
pkt_timebase: Array<number>
|
|
415
|
+
|
|
416
|
+
readonly codec_descriptor: {
|
|
417
|
+
INTRA_ONLY: boolean
|
|
418
|
+
LOSSY: boolean
|
|
419
|
+
LOSSLESS: boolean
|
|
420
|
+
REORDER: boolean
|
|
421
|
+
BITMAP_SUB: boolean
|
|
422
|
+
TEXT_SUB: boolean
|
|
423
|
+
} | null
|
|
424
|
+
/** Character encoding of the input subtitles file. */
|
|
425
|
+
sub_charenc: string | null
|
|
426
|
+
/**
|
|
427
|
+
* Subtitles character encoding mode. Formats or codecs might be adjusting
|
|
428
|
+
* this setting (if they are doing the conversion themselves for instance).
|
|
429
|
+
*/
|
|
430
|
+
readonly sub_charenc_mode: 'do-nothing' | 'automatic' | 'pre-decoder' | 'ignore'
|
|
431
|
+
/**
|
|
432
|
+
* Skip processing alpha if supported by codec.
|
|
433
|
+
* Note that if the format uses pre-multiplied alpha (common with VP6,
|
|
434
|
+
* and recommended due to better video quality/compression)
|
|
435
|
+
* the image will look as if alpha-blended onto a black background.
|
|
436
|
+
* However for formats that do not use pre-multiplied alpha
|
|
437
|
+
* there might be serious artefacts (though e.g. libswscale currently
|
|
438
|
+
* assumes pre-multiplied alpha anyway).
|
|
439
|
+
*/
|
|
440
|
+
skip_alpha: number
|
|
441
|
+
/** Number of samples to skip after a discontinuity */
|
|
442
|
+
readonly seek_preroll: number
|
|
443
|
+
/** custom intra quantization matrix */
|
|
444
|
+
chroma_intra_matrix: Array<number>
|
|
445
|
+
/** Dump format separator - can be ", " or "\n " or anything else */
|
|
446
|
+
dump_separator: string | null
|
|
447
|
+
/** ',' separated list of allowed decoders - if null then all are allowed */
|
|
448
|
+
codec_whitelist: string | null
|
|
449
|
+
/** Properties of the stream that gets decoded */
|
|
450
|
+
readonly properties: { LOSSLESS: boolean, CLOSED_CAPTIONS: boolean }
|
|
451
|
+
/** Additional data associated with the entire coded stream. */
|
|
452
|
+
readonly coded_side_data: {
|
|
453
|
+
type: 'PacketSideData'
|
|
454
|
+
[key: string]: Buffer | string
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* A reference to the AVHWFramesContext describing the input (for encoding)
|
|
458
|
+
* or output (decoding) frames. The reference is set by the caller and
|
|
459
|
+
* afterwards owned (and freed) by libavcodec - it should never be read by
|
|
460
|
+
* the caller after being set.
|
|
461
|
+
*
|
|
462
|
+
* - decoding: This field should be set by the caller from the get_format()
|
|
463
|
+
* callback. The previous reference (if any) will always be
|
|
464
|
+
* unreffed by libavcodec before the get_format() call.
|
|
465
|
+
*
|
|
466
|
+
* If the default get_buffer2() is used with a hwaccel pixel
|
|
467
|
+
* format, then this AVHWFramesContext will be used for
|
|
468
|
+
* allocating the frame buffers.
|
|
469
|
+
*
|
|
470
|
+
* - encoding: For hardware encoders configured to use a hwaccel pixel
|
|
471
|
+
* format, this field should be set by the caller to a reference
|
|
472
|
+
* to the AVHWFramesContext describing input frames.
|
|
473
|
+
* AVHWFramesContext.format must be equal to
|
|
474
|
+
* AVCodecContext.pix_fmt.
|
|
475
|
+
*
|
|
476
|
+
* This field should be set before avcodec_open2() is called.
|
|
477
|
+
*/
|
|
478
|
+
hw_frames_ctx: HWFramesContext
|
|
479
|
+
/** Control the form of AVSubtitle.rects[N]->ass */
|
|
480
|
+
sub_text_format: number
|
|
481
|
+
/**
|
|
482
|
+
* Audio only. The amount of padding (in samples) appended by the encoder to
|
|
483
|
+
* the end of the audio. I.e. this number of decoded samples must be
|
|
484
|
+
* discarded by the caller from the end of the stream to get the original
|
|
485
|
+
* audio without any trailing padding.
|
|
486
|
+
*/
|
|
487
|
+
trailing_padding: number
|
|
488
|
+
/** The number of pixels per image to maximally accept. */
|
|
489
|
+
max_pixels: number
|
|
490
|
+
/**
|
|
491
|
+
* A reference to the HWDeviceContext describing the device which will
|
|
492
|
+
* be used by a hardware encoder/decoder. The reference is set by the
|
|
493
|
+
* caller and afterwards owned (and freed) by libavcodec.
|
|
494
|
+
*
|
|
495
|
+
* This should be used if either the codec device does not require
|
|
496
|
+
* hardware frames or any that are used are to be allocated internally by
|
|
497
|
+
* libavcodec. If the user wishes to supply any of the frames used as
|
|
498
|
+
* encoder input or decoder output then hw_frames_ctx should be used
|
|
499
|
+
* instead. When hw_frames_ctx is set in get_format() for a decoder, this
|
|
500
|
+
* field will be ignored while decoding the associated stream segment, but
|
|
501
|
+
* may again be used on a following one after another get_format() call.
|
|
502
|
+
*
|
|
503
|
+
* For both encoders and decoders this field should be set before
|
|
504
|
+
* avcodec_open2() is called and must not be written to thereafter.
|
|
505
|
+
*
|
|
506
|
+
* Note that some decoders may require this field to be set initially in
|
|
507
|
+
* order to support hw_frames_ctx at all - in that case, all frames
|
|
508
|
+
* contexts used must be created on the same device.
|
|
509
|
+
*/
|
|
510
|
+
hw_device_ctx: HWDeviceContext
|
|
511
|
+
/**
|
|
512
|
+
* Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated
|
|
513
|
+
* decoding (if active).
|
|
514
|
+
*/
|
|
515
|
+
hwaccel_flags: { IGNORE_LEVEL?: boolean, ALLOW_HIGH_DEPTH?: boolean, ALLOW_PROFILE_MISMATCH?: boolean }
|
|
516
|
+
/**
|
|
517
|
+
* Video decoding only. Certain video codecs support cropping, meaning that
|
|
518
|
+
* only a sub-rectangle of the decoded frame is intended for display. This
|
|
519
|
+
* option controls how cropping is handled by libavcodec.
|
|
520
|
+
*
|
|
521
|
+
* When set to 1 (the default), libavcodec will apply cropping internally.
|
|
522
|
+
* I.e. it will modify the output frame width/height fields and offset the
|
|
523
|
+
* data pointers (only by as much as possible while preserving alignment, or
|
|
524
|
+
* by the full amount if the AV_CODEC_FLAG_UNALIGNED flag is set) so that
|
|
525
|
+
* the frames output by the decoder refer only to the cropped area. The
|
|
526
|
+
* crop_* fields of the output frames will be zero.
|
|
527
|
+
*
|
|
528
|
+
* When set to 0, the width/height fields of the output frames will be set
|
|
529
|
+
* to the coded dimensions and the crop_* fields will describe the cropping
|
|
530
|
+
* rectangle. Applying the cropping is left to the caller.
|
|
531
|
+
*
|
|
532
|
+
* @warning When hardware acceleration with opaque output frames is used,
|
|
533
|
+
* libavcodec is unable to apply cropping from the top/left border.
|
|
534
|
+
*
|
|
535
|
+
* @note when this option is set to zero, the width/height fields of the
|
|
536
|
+
* AVCodecContext and output AVFrames have different meanings. The codec
|
|
537
|
+
* context fields store display dimensions (with the coded dimensions in
|
|
538
|
+
* coded_width/height), while the frame fields store the coded dimensions
|
|
539
|
+
* (with the display dimensions being determined by the crop_* fields).
|
|
540
|
+
*/
|
|
541
|
+
apply_cropping: number
|
|
542
|
+
/*
|
|
543
|
+
* Video decoding only. Sets the number of extra hardware frames which
|
|
544
|
+
* the decoder will allocate for use by the caller. This must be set
|
|
545
|
+
* before avcodec_open2() is called.
|
|
546
|
+
*
|
|
547
|
+
* Some hardware decoders require all frames that they will use for
|
|
548
|
+
* output to be defined in advance before decoding starts. For such
|
|
549
|
+
* decoders, the hardware frame pool must therefore be of a fixed size.
|
|
550
|
+
* The extra frames set here are on top of any number that the decoder
|
|
551
|
+
* needs internally in order to operate normally (for example, frames
|
|
552
|
+
* used as reference pictures).
|
|
553
|
+
*/
|
|
554
|
+
extra_hw_frames: number
|
|
555
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CodecPar describes the properties of an encoded stream.
|
|
3
|
+
*/
|
|
4
|
+
export interface CodecPar {
|
|
5
|
+
/** Object name. */
|
|
6
|
+
readonly type: 'CodecParameters'
|
|
7
|
+
/** General type of the encoded data. */
|
|
8
|
+
codec_type: string
|
|
9
|
+
/** Specific type of the encoded data (the codec used). */
|
|
10
|
+
codec_id: number
|
|
11
|
+
/** The name corresponding to the codec_id. */
|
|
12
|
+
name: string
|
|
13
|
+
/** Additional information about the codec (corresponds to the AVI FOURCC). */
|
|
14
|
+
codec_tag: string
|
|
15
|
+
/** Extra binary data needed for initializing the decoder, codec-dependent. */
|
|
16
|
+
extradata: Buffer
|
|
17
|
+
/**
|
|
18
|
+
* - video: the pixel format.
|
|
19
|
+
* - audio: the sample format.
|
|
20
|
+
*/
|
|
21
|
+
format: string
|
|
22
|
+
/** The average bitrate of the encoded data (in bits per second). */
|
|
23
|
+
bit_rate: number
|
|
24
|
+
/**
|
|
25
|
+
* The number of bits per sample in the codedwords.
|
|
26
|
+
*
|
|
27
|
+
* This is basically the bitrate per sample. It is mandatory for a bunch of
|
|
28
|
+
* formats to actually decode them. It's the number of bits for one sample in
|
|
29
|
+
* the actual coded bitstream.
|
|
30
|
+
*
|
|
31
|
+
* This could be for example 4 for ADPCM
|
|
32
|
+
* For PCM formats this matches bits_per_raw_sample
|
|
33
|
+
* Can be 0
|
|
34
|
+
*/
|
|
35
|
+
bits_per_coded_sample: number
|
|
36
|
+
/**
|
|
37
|
+
* This is the number of valid bits in each output sample. If the
|
|
38
|
+
* sample format has more bits, the least significant bits are additional
|
|
39
|
+
* padding bits, which are always 0. Use right shifts to reduce the sample
|
|
40
|
+
* to its actual size. For example, audio formats with 24 bit samples will
|
|
41
|
+
* have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32.
|
|
42
|
+
* To get the original sample use "(int32_t)sample >> 8"."
|
|
43
|
+
*
|
|
44
|
+
* For ADPCM this might be 12 or 16 or similar
|
|
45
|
+
* Can be 0
|
|
46
|
+
*/
|
|
47
|
+
bits_per_raw_sample: number
|
|
48
|
+
/** Codec-specific bitstream restrictions that the stream conforms to. */
|
|
49
|
+
profile: string | number
|
|
50
|
+
level: number
|
|
51
|
+
/** Video only. The video frame width in pixels. */
|
|
52
|
+
width: number
|
|
53
|
+
/** Video only. The video frame height in pixels. */
|
|
54
|
+
height: number
|
|
55
|
+
/**
|
|
56
|
+
* Video only. The aspect ratio (width / height) which a single pixel
|
|
57
|
+
* should have when displayed.
|
|
58
|
+
*
|
|
59
|
+
* When the aspect ratio is unknown / undefined, the numerator should be
|
|
60
|
+
* set to 0 (the denominator may have any value).
|
|
61
|
+
*/
|
|
62
|
+
sample_aspect_ratio: Array<number>
|
|
63
|
+
/** Video only. The order of the fields in interlaced video. */
|
|
64
|
+
field_order: string
|
|
65
|
+
/** Video only. Additional colorspace characteristics. */
|
|
66
|
+
color_range: string
|
|
67
|
+
color_primaries: string
|
|
68
|
+
color_trc: string
|
|
69
|
+
color_space: string
|
|
70
|
+
chroma_location: string
|
|
71
|
+
/** Video only. Number of delayed frames. */
|
|
72
|
+
video_delay: number
|
|
73
|
+
/** Audio only. A description of the channel layout. */
|
|
74
|
+
channel_layout: string
|
|
75
|
+
/** Audio only. The number of audio channels. */
|
|
76
|
+
channels: number
|
|
77
|
+
/** Audio only. The number of audio samples per second. */
|
|
78
|
+
sample_rate: number
|
|
79
|
+
/**
|
|
80
|
+
* Audio only. The number of bytes per coded audio frame, required by some
|
|
81
|
+
* formats.
|
|
82
|
+
*
|
|
83
|
+
* Corresponds to nBlockAlign in WAVEFORMATEX.
|
|
84
|
+
*/
|
|
85
|
+
block_align: number
|
|
86
|
+
/** Audio only. Audio frame size, if known. Required by some formats to be static. */
|
|
87
|
+
frame_size: number
|
|
88
|
+
/**
|
|
89
|
+
* Audio only. The amount of padding (in samples) inserted by the encoder at
|
|
90
|
+
* the beginning of the audio. I.e. this number of leading decoded samples
|
|
91
|
+
* must be discarded by the caller to get the original audio without leading
|
|
92
|
+
* padding.
|
|
93
|
+
*/
|
|
94
|
+
initial_padding: number
|
|
95
|
+
/**
|
|
96
|
+
* Audio only. The amount of padding (in samples) appended by the encoder to
|
|
97
|
+
* the end of the audio. I.e. this number of decoded samples must be
|
|
98
|
+
* discarded by the caller from the end of the stream to get the original
|
|
99
|
+
* audio without any trailing padding.
|
|
100
|
+
*/
|
|
101
|
+
trailing_padding: number
|
|
102
|
+
/** Audio only. Number of samples to skip after a discontinuity. */
|
|
103
|
+
seek_preroll: number
|
|
104
|
+
/** Retun a JSON string containing the object properties. */
|
|
105
|
+
toJSON(): string
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function codecParameters(options?: { [key: string]: any }): CodecPar;
|