VideoCompressionRequest constructor
VideoCompressionRequest({
- required String inputPath,
- required String outputPath,
- required VideoCodec codec,
- required ContainerFormat container,
- required int averageBitrate,
- int? width,
- int? height,
- int? maxShortSide,
- double? maxFrameRate,
- double gopSeconds = 2,
- bool removeAudio = false,
- VideoHdrPolicy hdrPolicy = VideoHdrPolicy.keepOriginal,
Implementation
VideoCompressionRequest({
required this.inputPath,
required this.outputPath,
required this.codec,
required this.container,
required this.averageBitrate,
this.width,
this.height,
this.maxShortSide,
this.maxFrameRate,
this.gopSeconds = 2,
this.removeAudio = false,
this.hdrPolicy = VideoHdrPolicy.keepOriginal,
}) {
if (inputPath.isEmpty || outputPath.isEmpty) {
throw ArgumentError('inputPath and outputPath must not be empty');
}
if (averageBitrate <= 0) {
throw ArgumentError.value(
averageBitrate,
'averageBitrate',
'must be positive',
);
}
if ((width == null) != (height == null)) {
throw ArgumentError('width and height must be provided together');
}
if (width != null && (width! <= 0 || height! <= 0)) {
throw ArgumentError('width and height must be positive');
}
if (maxShortSide != null && maxShortSide! <= 0) {
throw ArgumentError.value(
maxShortSide,
'maxShortSide',
'must be positive',
);
}
if (maxShortSide != null && width != null) {
throw ArgumentError(
'maxShortSide and explicit width/height are mutually exclusive',
);
}
if (maxFrameRate != null &&
(!maxFrameRate!.isFinite || maxFrameRate! <= 0)) {
throw ArgumentError.value(
maxFrameRate,
'maxFrameRate',
'must be positive',
);
}
if (!gopSeconds.isFinite || gopSeconds <= 0) {
throw ArgumentError.value(gopSeconds, 'gopSeconds', 'must be positive');
}
}