setVideoSettings method

Future<void> setVideoSettings({
  1. int? bitrate,
  2. int? width,
  3. int? height,
  4. int? frameInterval,
  5. String? profileLevel,
  6. double? expectedFrameRate,
  7. String? bitRateMode,
})

set video Settings

expectedFrameRate:HaishinKit 2.2.2+,写入编码期望帧率并进入 RTMP onMetaData 的 framerate

bitRateModeaverage(默认)、constant(iOS 16+)、variable(iOS 26+,对应 VideoToolbox VBR)。 Only supports ios

Implementation

Future<void> setVideoSettings(
    {int? bitrate,
    int? width,
    int? height,
    int? frameInterval,
    String? profileLevel,
    double? expectedFrameRate,
    String? bitRateMode}) async {
  if (!value.isInitialized! || _isDisposed) {
    throw CameraException(
      'Uninitialized CameraController',
      'setVideoSettings was called on uninitialized CameraController',
    );
  }
  if (!Platform.isIOS) {
    throw CameraException(
      'Unsupported platforms.',
      'setVideoSettings Only supports Ios.',
    );
  }
  try {
    await _channel.invokeMethod<void>(
      'setVideoSettings',
      <String, dynamic>{
        "bitrate": bitrate,
        "width": width,
        "height": height,
        "frameInterval": frameInterval,
        "profileLevel": profileLevel,
        if (expectedFrameRate != null) "expectedFrameRate": expectedFrameRate,
        if (bitRateMode != null) "bitRateMode": bitRateMode,
      },
    );
  } on PlatformException catch (e) {
    throw CameraException(e.code, e.message);
  }
}