VideoCompressionRequest constructor

VideoCompressionRequest({
  1. required String inputPath,
  2. required String outputPath,
  3. required VideoCodec codec,
  4. required ContainerFormat container,
  5. required int averageBitrate,
  6. int? width,
  7. int? height,
  8. int? maxShortSide,
  9. double? maxFrameRate,
  10. double gopSeconds = 2,
  11. bool removeAudio = false,
  12. 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');
  }
}