-
Notifications
You must be signed in to change notification settings - Fork 10
/
H264VideoConfiguration.ts
412 lines (362 loc) · 13.5 KB
/
H264VideoConfiguration.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
import {map, mapArray} from '../common/Mapper';
import AdaptiveQuantMode from './AdaptiveQuantMode';
import AutoLevelSetup from './AutoLevelSetup';
import BAdapt from './BAdapt';
import Cea608708SubtitleConfiguration from './Cea608708SubtitleConfiguration';
import CodecConfigType from './CodecConfigType';
import ColorConfig from './ColorConfig';
import DisplayAspectRatio from './DisplayAspectRatio';
import EncodingMode from './EncodingMode';
import H264BPyramid from './H264BPyramid';
import H264DynamicRangeFormat from './H264DynamicRangeFormat';
import H264InterlaceMode from './H264InterlaceMode';
import H264MotionEstimationMethod from './H264MotionEstimationMethod';
import H264NalHrd from './H264NalHrd';
import H264Partition from './H264Partition';
import H264SubMe from './H264SubMe';
import H264Trellis from './H264Trellis';
import LevelH264 from './LevelH264';
import MvPredictionMode from './MvPredictionMode';
import PixelFormat from './PixelFormat';
import PresetConfiguration from './PresetConfiguration';
import ProfileH264 from './ProfileH264';
import VideoConfiguration from './VideoConfiguration';
import WeightedPredictionPFrames from './WeightedPredictionPFrames';
/**
* @export
* @class H264VideoConfiguration
*/
export class H264VideoConfiguration extends VideoConfiguration {
/**
* Discriminator property for CodecConfiguration
* @type {string}
* @memberof H264VideoConfiguration
*/
public readonly type: CodecConfigType = CodecConfigType.H264;
/**
* Choose from a set of preset configurations tailored for common use cases. Check out [H264 Presets](https://bitmovin.com/docs/encoding/tutorials/h264-presets) to see which values get applied by each preset. Explicitly setting a property to a different value will override the preset's value for that property.
* @type {PresetConfiguration}
* @memberof H264VideoConfiguration
*/
public presetConfiguration?: PresetConfiguration;
/**
* Automatically configures the H264 Video Codec to be compatible with the given SDR format. Bitmovin recommends to use the dynamic range format together with a preset configuration to achieve good results. Explicitly configured properties will take precedence over dynamic range format settings, which in turn will take precedence over preset configurations.
* @type {H264DynamicRangeFormat}
* @memberof H264VideoConfiguration
*/
public dynamicRangeFormat?: H264DynamicRangeFormat;
/**
* Constant rate factor for quality-based variable bitrate. Either bitrate or crf is required.
* @type {number}
* @memberof H264VideoConfiguration
*/
public crf?: number;
/**
* When setting a profile, all other settings must not exceed the limits which are defined in the profile. Otherwise, a higher profile may be automatically chosen. (required)
* @type {ProfileH264}
* @memberof H264VideoConfiguration
*/
public profile?: ProfileH264;
/**
* Amount of b frames
* @type {number}
* @memberof H264VideoConfiguration
*/
public bframes?: number;
/**
* Amount of reference frames.
* @type {number}
* @memberof H264VideoConfiguration
*/
public refFrames?: number;
/**
* Minimum quantization factor
* @type {number}
* @memberof H264VideoConfiguration
*/
public qpMin?: number;
/**
* Maximum quantization factor
* @type {number}
* @memberof H264VideoConfiguration
*/
public qpMax?: number;
/**
* @type {MvPredictionMode}
* @memberof H264VideoConfiguration
*/
public mvPredictionMode?: MvPredictionMode;
/**
* Maximum motion vector search range
* @type {number}
* @memberof H264VideoConfiguration
*/
public mvSearchRangeMax?: number;
/**
* Enable or disable CABAC
* @type {boolean}
* @memberof H264VideoConfiguration
*/
public cabac?: boolean;
/**
* Maximum Bitrate
* @type {number}
* @memberof H264VideoConfiguration
*/
public maxBitrate?: number;
/**
* Minimum Bitrate
* @type {number}
* @memberof H264VideoConfiguration
*/
public minBitrate?: number;
/**
* Playback device buffer size
* @type {number}
* @memberof H264VideoConfiguration
*/
public bufsize?: number;
/**
* Minimum GOP length, the minimum distance between I-frames
* @type {number}
* @memberof H264VideoConfiguration
*/
public minGop?: number;
/**
* Maximum GOP length, the maximum distance between I-frames
* @type {number}
* @memberof H264VideoConfiguration
*/
public maxGop?: number;
/**
* Enable open-gop, allows referencing frames from a previous gop
* @type {boolean}
* @memberof H264VideoConfiguration
*/
public openGop?: boolean;
/**
* Minimum interval in seconds between key frames
* @type {number}
* @memberof H264VideoConfiguration
*/
public minKeyframeInterval?: number;
/**
* Maximum interval in seconds between key frames
* @type {number}
* @memberof H264VideoConfiguration
*/
public maxKeyframeInterval?: number;
/**
* If three-pass encoding is used and a level is set for the encoder, the bitrate for some segments may exceed the bitrate limit which is defined by the level.
* @type {LevelH264}
* @memberof H264VideoConfiguration
*/
public level?: LevelH264;
/**
* @type {BAdapt}
* @memberof H264VideoConfiguration
*/
public bAdaptiveStrategy?: BAdapt;
/**
* @type {H264MotionEstimationMethod}
* @memberof H264VideoConfiguration
*/
public motionEstimationMethod?: H264MotionEstimationMethod;
/**
* Number of frames for frame-type decision lookahead
* @type {number}
* @memberof H264VideoConfiguration
*/
public rcLookahead?: number;
/**
* Subpixel motion estimation and mode decision
* @type {H264SubMe}
* @memberof H264VideoConfiguration
*/
public subMe?: H264SubMe;
/**
* Enables or disables Trellis quantization. NOTE: This requires cabac
* @type {H264Trellis}
* @memberof H264VideoConfiguration
*/
public trellis?: H264Trellis;
/**
* Partitions to consider. Analyzing more partition options improves quality at the cost of speed.
* @type {H264Partition[]}
* @memberof H264VideoConfiguration
*/
public partitions?: H264Partition[];
/**
* Number of slices per frame.
* @type {number}
* @memberof H264VideoConfiguration
*/
public slices?: number;
/**
* Using TOP_FIELD_FIRST or BOTTOM_FIELD_FIRST will output interlaced video
* @type {H264InterlaceMode}
* @memberof H264VideoConfiguration
*/
public interlaceMode?: H264InterlaceMode;
/**
* Scene change sensitivity. The higher the value, the more likely an I-frame will be inserted. Set to 0 to disable it which is advised for scenarios where fixed GOP is required, e.g., adaptive streaming outputs like DASH, HLS and Smooth. Having this setting enabled can improve quality for progressive output with an increased internal chunk length (see `internalChunkLength` of muxings).
* @type {number}
* @memberof H264VideoConfiguration
*/
public sceneCutThreshold?: number;
/**
* Signal hypothetical reference decoder (HRD) information (requires bufsize to be set)
* @type {H264NalHrd}
* @memberof H264VideoConfiguration
*/
public nalHrd?: H264NalHrd;
/**
* Keep some B-frames as references
* @type {H264BPyramid}
* @memberof H264VideoConfiguration
*/
public bPyramid?: H264BPyramid;
/**
* Defines whether CEA 608/708 subtitles are copied from the input video stream
* @type {Cea608708SubtitleConfiguration}
* @memberof H264VideoConfiguration
*/
public cea608708SubtitleConfig?: Cea608708SubtitleConfiguration;
/**
* Strength of the in-loop deblocking filter. Higher values deblock more effectively but also soften the image
* @type {number}
* @memberof H264VideoConfiguration
*/
public deblockAlpha?: number;
/**
* Threshold of the in-loop deblocking filter. Higher values apply deblocking stronger on non flat blocks, lower values on flat blocks
* @type {number}
* @memberof H264VideoConfiguration
*/
public deblockBeta?: number;
/**
* Controls the adaptive quantization algorithm
* @type {AdaptiveQuantMode}
* @memberof H264VideoConfiguration
*/
public adaptiveQuantizationMode?: AdaptiveQuantMode;
/**
* Values greater than 1 reduce blocking and blurring in flat and textured areas. Values less than 1 reduces ringing artifacts at the cost of more banding artifacts. Negative values are not allowed
* @type {number}
* @memberof H264VideoConfiguration
*/
public adaptiveQuantizationStrength?: number;
/**
* Allow references on a per partition basis, rather than per-macroblock basis
* @type {boolean}
* @memberof H264VideoConfiguration
*/
public mixedReferences?: boolean;
/**
* Enables adaptive spatial transform (high profile 8x8 transform)
* @type {boolean}
* @memberof H264VideoConfiguration
*/
public adaptiveSpatialTransform?: boolean;
/**
* Enables fast skip detection on P-frames. Disabling this very slightly increases quality but at a large speed loss
* @type {boolean}
* @memberof H264VideoConfiguration
*/
public fastSkipDetectionPFrames?: boolean;
/**
* Enable open-gop, allows referencing frames from a previous gop
* @type {boolean}
* @memberof H264VideoConfiguration
*/
public weightedPredictionBFrames?: boolean;
/**
* Defines the mode for weighted prediction for P-frames
* @type {WeightedPredictionPFrames}
* @memberof H264VideoConfiguration
*/
public weightedPredictionPFrames?: WeightedPredictionPFrames;
/**
* Enable macroblock tree ratecontrol. Macroblock tree rate control tracks how often blocks of the frame are used for prediciting future frames
* @type {boolean}
* @memberof H264VideoConfiguration
*/
public macroblockTreeRatecontrol?: boolean;
/**
* Ratio between constant bitrate (0.0) and constant quantizer (1.0). Valid range 0.0 - 1.0
* @type {number}
* @memberof H264VideoConfiguration
*/
public quantizerCurveCompression?: number;
/**
* Psychovisual Rate Distortion retains fine details like film grain at the expense of more blocking artifacts. Higher values make the video appear sharper and more detailed but with a higher risk of blocking artifacts. Needs to have subMe with RD_IP, RD_ALL, RD_REF_IP or RD_REF_ALL
* @type {number}
* @memberof H264VideoConfiguration
*/
public psyRateDistortionOptimization?: number;
/**
* Higher values will improve sharpness and detail retention but might come at costs of artifacts. Needs to have trellis enabled
* @type {number}
* @memberof H264VideoConfiguration
*/
public psyTrellis?: number;
/**
* Enable/disable automatic calculation of level, maxBitrate, and bufsize based on the least level that satisfies maximum property values for picture resolution, frame rate, and bit rate. In the case the target level is set explicitly, the maximum bitrate and buffer size are calculated based on the defined level. Explicitly setting maxBitrate, or bufsize properties will disable the automatic calculation.
* @type {AutoLevelSetup}
* @memberof H264VideoConfiguration
*/
public autoLevelSetup?: AutoLevelSetup;
constructor(obj?: Partial<H264VideoConfiguration>) {
super(obj);
if(!obj) {
return;
}
this.presetConfiguration = map(obj.presetConfiguration);
this.dynamicRangeFormat = map(obj.dynamicRangeFormat);
this.crf = map(obj.crf);
this.profile = map(obj.profile);
this.bframes = map(obj.bframes);
this.refFrames = map(obj.refFrames);
this.qpMin = map(obj.qpMin);
this.qpMax = map(obj.qpMax);
this.mvPredictionMode = map(obj.mvPredictionMode);
this.mvSearchRangeMax = map(obj.mvSearchRangeMax);
this.cabac = map(obj.cabac);
this.maxBitrate = map(obj.maxBitrate);
this.minBitrate = map(obj.minBitrate);
this.bufsize = map(obj.bufsize);
this.minGop = map(obj.minGop);
this.maxGop = map(obj.maxGop);
this.openGop = map(obj.openGop);
this.minKeyframeInterval = map(obj.minKeyframeInterval);
this.maxKeyframeInterval = map(obj.maxKeyframeInterval);
this.level = map(obj.level);
this.bAdaptiveStrategy = map(obj.bAdaptiveStrategy);
this.motionEstimationMethod = map(obj.motionEstimationMethod);
this.rcLookahead = map(obj.rcLookahead);
this.subMe = map(obj.subMe);
this.trellis = map(obj.trellis);
this.partitions = mapArray(obj.partitions);
this.slices = map(obj.slices);
this.interlaceMode = map(obj.interlaceMode);
this.sceneCutThreshold = map(obj.sceneCutThreshold);
this.nalHrd = map(obj.nalHrd);
this.bPyramid = map(obj.bPyramid);
this.cea608708SubtitleConfig = map(obj.cea608708SubtitleConfig, Cea608708SubtitleConfiguration);
this.deblockAlpha = map(obj.deblockAlpha);
this.deblockBeta = map(obj.deblockBeta);
this.adaptiveQuantizationMode = map(obj.adaptiveQuantizationMode);
this.adaptiveQuantizationStrength = map(obj.adaptiveQuantizationStrength);
this.mixedReferences = map(obj.mixedReferences);
this.adaptiveSpatialTransform = map(obj.adaptiveSpatialTransform);
this.fastSkipDetectionPFrames = map(obj.fastSkipDetectionPFrames);
this.weightedPredictionBFrames = map(obj.weightedPredictionBFrames);
this.weightedPredictionPFrames = map(obj.weightedPredictionPFrames);
this.macroblockTreeRatecontrol = map(obj.macroblockTreeRatecontrol);
this.quantizerCurveCompression = map(obj.quantizerCurveCompression);
this.psyRateDistortionOptimization = map(obj.psyRateDistortionOptimization);
this.psyTrellis = map(obj.psyTrellis);
this.autoLevelSetup = map(obj.autoLevelSetup);
}
}
export default H264VideoConfiguration;