• 【转】开源视频录制库LandscapeVideoCamera


    非常强大的android 视频录制库,可以选择视频尺寸以及视频质量,只允许横屏录制。

    使用Android自带的Camera应用可以录制视频,只需发送MediaStore.ACTION_VIDEO_CAPTURE的intent即可,但是有一些缺陷:

    内置应用intent的视频质量参数只允许为0和1 分别代表最低质量和最高质量,这个参数是一个extra 参数:MediaStore.EXTRA_VIDEO_QUALITY

    在指定了文件名的情况下,内置应用intent不会返回录制完视频的URI

    内置应用intent不关心用户录制的视频是横屏还是竖屏的。

    截图

    LandscapeVideoCamera的特点

    LandscapeVideoCamera提供了完整的可复用的自定义camera,有如下特点:

    (1)强制用户横屏录制(当为竖屏的时候是不能录制的)

    (2)允许指定录制视频的文件名,当然也支持自动生成文件名。

    (3)允许改变如下设置:

       分辨率

       码率

       视频文件最大占用空间

       视频录制时间

    使用

    将LandscapeVideoCamera库添加进你的项目中

    在manifest中添加VideoCaptureActivity :

    1 <activity
    2     android:name="com.jmolsmobile.landscapevideocapture.VideoCaptureActivity"
    3     android:screenOrientation="sensor" >
    4 </activity>

    在manifest中添加如下权限:

    1 <uses-permission android:name="android.permission.RECORD_AUDIO" />
    2 <uses-permission android:name="android.permission.CAMERA" />
    3 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     

    设置录制参数,创建CaptureConfiguration对象,根据需要选择合适的构造方法,有如下构造方法:

    1 Capture configuration = CaptureConfiguration(CaptureResolution resolution, CaptureQuality quality);
    2 Capture configuration = CaptureConfiguration(CaptureResolution resolution, CaptureQuality quality, int maxDurationSecs, int maxFilesizeMb);
    3 Capture configuration = CaptureConfiguration(int videoWidth, int videoHeight, int bitrate);
    4 Capture configuration = CaptureConfiguration(int videoWidth, int videoHeight, int bitrate, int maxDurationSecs, int maxFilesizeMb);
     

    如果没有设置CaptureConfiguration 则会使用默认的设置。

    用 startActivityForResult调用VideoCaptureActivity,CaptureConfiguration 作为parcelable类型参数EXTRA_CAPTURE_CONFIGURATION传递,文件名作为String类型参数 EXTRA_OUTPUT_FILENAME传递。

    1 final Intent intent = new Intent(getActivity(), VideoCaptureActivity.class);
    2 intent.putExtra(VideoCaptureActivity.EXTRA_CAPTURE_CONFIGURATION, config);
    3 intent.putExtra(VideoCaptureActivity.EXTRA_OUTPUT_FILENAME, filename);
    4 startActivityForResult(intent, RESULT_CODE);
     

    检查resultcode (RESULT_OK, RESULT_CANCELLED或者VideoCaptureActivity.RESULT_ERROR) ,如果成功则从intent extra 的EXTRA_OUTPUT_FILENAME中得到文件名。

    项目地址:http://jcodecraeer.com/a/opensource/2014/1213/2156.html

  • 相关阅读:
    [dfs+水] hdu 4462 Scaring the Birds
    [Leetcode]-containsNearbyDuplicate
    測试流程的规范性与重要性
    柯里化函数之Javascript
    android AChartEngine源代码
    Android高斯模糊
    linux64位系统中g++4.4.7下使用wcsncpy函数有造成段错误的BUG(其它g++版本号未知)
    便利贴女孩_百度百科
    法爱格官方旗舰店
    法爱格2014 春夏新款欧美纯色修身高腰无袖吊带V领 拼接性感 连衣裙 黑色 M【图片 价格 品牌 报价】-京东
  • 原文地址:https://www.cnblogs.com/liangstudyhome/p/4168434.html
Copyright © 2020-2023  润新知