录制视频时想获取手机支持的录制视频的分辨率,使用代码如下:

List<Camera.Size> videoSize = camera.getParameters().getSupportedVideoSizes();
Iterator<Camera.Size> itos = videoSize.iterator();
while (itos.hasNext()) {
Camera.Size curSize = itos.next();
int curSupporSize = curSize.width * curSize.height;
int fixPictrueSize = setFixPictureWidth * setFixPictureHeight;
if (curSupporSize > fixPictrueSize) {
setFixPictureWidth = curSize.width;
setFixPictureHeight = curSize.height;
}
}
mediaRecorder.setVideoSize(setFixPictureWidth,
setFixPictureHeight);

出现了两次错误,一次是录制视频时调用camera.getParameters()时报parameters is empty,这是由于在camera.unlock()之后调用了该函数,将其在unlock之前获取就ok了。
还有一个错误就是setVideoSize called in a invalid state 1,进入setVideoSize函数中可以发现抛出异常的条件说明

 /**
* Sets the width and height of the video to be captured. Must be called
* after setVideoSource(). Call this after setOutFormat() but before
* prepare().
*
* @param width the width of the video to be captured
* @param height the height of the video to be captured
* @throws IllegalStateException if it is called after
* prepare() or before setOutputFormat()
*/
public native void setVideoSize(int width, int height)
throws IllegalStateException;

IllegalStateException if it is called after prepare() or before setOutputFormat()表示如果setVideoSize在prepare() 之后或者setOutputFormat()之前调用的话就会出现该异常,即是说要求setVideoSize函数在prepare()之前以及setOutputFormat()之后调用。
查了下代码,发现我调用setVideoSize竟然是在setOutputFormat()之前,改到setOutputFormat()之后就ok了。

Android录制视频报错setVideoSize called in a invalid state 1的更多相关文章

  1. MediaPlayer 播放assets 文件夹下面的视频报错

    Android MediaPlayer 播放assets 文件夹下面的视频报错 报下面的错: java.io.FileNotFoundException: This file can not be o ...

  2. android sdk启动报错error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037:

    android sdk启动报错error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037: 问题原因: ...

  3. react native-调用react-native-fs插件时,如果数据的接口是需要验证信息的,在android上运行报错

    调用react-native-fs插件时,如果数据的接口是需要验证信息的,在android上运行报错,而在iOS上运行没问题.原因是因为接口是有验证信息的,而调用这个插件时没有传入,在iOS上会自动加 ...

  4. 解决Android Studio Conflict with dependency 'com.android.support:support-annotations'报错

    解决Android Studio Conflict with dependency 'com.android.support:support-annotations'报错 在Android Studi ...

  5. sqlplus 连接数据库报错SP2-0642: SQL*Plus internal error state 2130, context 0:0:0

    sqlplus 连接数据库报错SP2-0642: SQL*Plus internal error state 2130, context 0:0:0 问题描述: 使用sqlplus客户端登录数据库,报 ...

  6. 运行报错:java.io.IOException: invalid constant type: 15

    jdk,tomcat更新到jdk1.8与 tomcat8 运行报错:java.io.IOException: invalid constant type: 15 pom.xml文件中更新javassi ...

  7. Poi读取Excle报错 java.util.zip.ZipException: invalid stored block lengths

    一:Poi读取Excle报错  java.util.zip.ZipException: invalid stored block lengths 系统中需要导出excle签收单,excle模板是预设好 ...

  8. JavaWeb报错:java.sql.SQLException: Invalid value for getInt()

    1.错误描述:在对数据库进行操作时,控制台报错:java.sql.SQLException: Invalid value for getInt() :2.错误原因:数据库中表的字段的类型与实体类中属性 ...

  9. spark提交任务报错: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

    spark提交任务报错: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes ...

随机推荐

  1. c++ 2.1 编译器何时创建默认构造函数

    我们通常会说当生命一个 class 时,如果我们不为该 class 指定一个 constructor,那么编译器会替我们实现一个 connstructor,那么这种说法一定对吗? 事实上,这是不对的. ...

  2. poj1273 网络流入门题 dinic算法解决,可作模板使用

    Drainage Ditches Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 62078   Accepted: 2384 ...

  3. 【R】多元线性回归

    R中的线性回归函数比较简单,就是lm(),比较复杂的是对线性模型的诊断和调整.这里结合Statistical Learning和杜克大学的Data Analysis and Statistical I ...

  4. 通过VS2010性能分析来查找代码中那些地方最损耗资源

    在编写完成一个程序后,大家都比较关心程序的性能如何,想把程序优化得更好.很多时候凭个人直觉来优化程序是件非常不靠普的事情,即使你是一个优秀的开人员也很难准确地判断程序中那些出现问题.VS2010提供了 ...

  5. unicode 编码在线转换工具--javascript

    http://www.cnblogs.com/mq0036/p/4007452.html

  6. springBoot 微服务

    微服务,是OO (面向对象,Object Oriented) 专家 Martin Fowler 于2014年在他一篇文章<Microservice>提出的.在 Mattin 的头脑中,兴奋 ...

  7. css3帮你轻松实现圆角效果,不一样的前端页面。

    在Web前端页面实现圆角效果,CSS3帮你轻松实现,一个人人皆知的属性 圆角边框的绘制是Web页面和Web应用程序中经常用来美化页面效果的手法之一.今天,小编为大家介绍CSS3提供的可以将矩形变为圆角 ...

  8. codeforces-574B

    题目连接:http://codeforces.com/contest/574/problem/B B. Bear and Three Musketeers time limit per test 2 ...

  9. Xamarin XAML语言教程构建进度条ProgressBar

    Xamarin XAML语言教程构建进度条ProgressBar Xamarin XAML语言教程构建进度条ProgressBar,ProgressBar被称为进度条,它类似于没有滑块的滑块控件.进度 ...

  10. Strobogrammatic Number -- LeetCode

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...