最近在学习使用camera2录制视频时发生报错:
E/MediaRecorder: prepare failed: -2147483648
比较神奇的是在android studio上自带的模拟器是不会出这个错的,但是视频不能自己保存。在我自己的华为手机上则直接报错,报错地址指向MediaRecorder的prepare方法。
首先我们看MediaRecorder的源码内容
/**
* Prepares the recorder to begin capturing and encoding data. This method
* must be called after setting up the desired audio and video sources,
* encoders, file format, etc., but before start().
*
* @throws IllegalStateException if it is called after
* start() or before setOutputFormat().
* @throws IOException if prepare fails otherwise.
*/
public