Android 6.0.1上的Flutter Camera视频录制抛出错误

问题描述

我正在使用camera插件在android中拍照和录像。 在大多数具有高api的设备中一切正常,但是当我想在一些具有低api的设备中 startVideoRecording stopVideoRecording 时出现错误

这是我开始录制视频后得到的日志。

I/Timeline( 2896): Timeline: Activity_idle id: android.os.BinderProxy@22d8a63 time:49383500
I/Timeline( 2896): Timeline: Activity_idle id: android.os.BinderProxy@22d8a63 time:49384645
I/Timeline( 2896): Timeline: Activity_idle id: android.os.BinderProxy@22d8a63 time:49385598
I/CameraManagerGlobal( 2896): Connecting to camera service
I/CameraManager( 2896): Using legacy camera HAL.
I/CameraDeviceState( 2896): Legacy camera service transitioning to state CONfigURING
I/RequestThread-0( 2896): Configure outputs: 2 surfaces configured.
D/Camera  ( 2896): app passed NULL surface
I/RequestThread-0( 2896): configureOutputs - set take picture size to 1920x1080
I/CameraDeviceState( 2896): Legacy camera service transitioning to state IDLE
I/RequestQueue( 2896): Repeating capture request set.
W/LegacyRequestMapper( 2896): convertRequestMetadata - control.awbRegions setting is not supported,ignoring value
W/LegacyRequestMapper( 2896): Only received metering rectangles with weight 0.
W/LegacyRequestMapper( 2896): Only received metering rectangles with weight 0.
I/CameraDeviceState( 2896): Legacy camera service transitioning to state CAPTURING
I/RequestQueue( 2896): Repeating capture request cancelled.
I/CameraDeviceState( 2896): Legacy camera service transitioning to state IDLE
E/CameraDevice-0-LE( 2896): Surface with size (w=1920,h=1080) and format 0x1 is not valid,size not in valid set: [1280x960,1280x720,640x480,480x640,352x288,320x240,240x320,176x144,144x176]
W/CameraDevice-JV-0( 2896): Stream configuration Failed
E/CameraCaptureSession( 2896): Session 1: Failed to create capture session; configuration Failed
Flutter doctor -v的

日志:

[✓] Flutter (Channel stable,1.22.1,on Mac OS X 10.14.6 18G5033,locale en-US)
    • Flutter version 1.22.1 at /Users/taleb/Developer/Flutter
    • Framework revision f30b7f4db9 (13 days ago),2020-10-08 10:06:30 -0700
    • Engine revision 75bef9f6c8
    • Dart version 2.10.1


[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/taleb/Library/Android/sdk
    • Platform android-30,build-tools 30.0.2
    • ANDROID_HOME = /Users/taleb/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.0,Build version 11A420a
    • CocoaPods version 1.8.3

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[!] IntelliJ IDEA Ultimate Edition (version 2019.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    • Dart plugin version 193.5731
    • For @R_682_4045@ion about installing plugins,see
      https://Flutter.dev/intellij-setup/#installing-the-plugins

[✓] Connected device (1 available)
    • P024 (mobile) • 192.168.43.200:5555 • android-arm • Android 6.0.1 (API 23)

! Doctor found issues in 2 categories.

解决方法

尝试使用较低的CameraController预设值

new CameraController(cameras[0],ResolutionPreset.low);