当前位置:操作系统 > 安卓/Android >>

android录制更大视频文件的修改

android录像的视频文件最大只有2GB,录制更大视频文件的修改


1. 首先Application需要Set 64bit Offset的属性给Writer.

frameworks/base/media/java/android/media/MediaRecorder.java
public void setVideoEncodingBitRate(int bitRate)
{
    ...
    setParameter("video-param-encoding-bitrate=" + bitRate);
    // To revise the 2GB file size limit. 添加下面这一行
    setParameter("param-use-64bit-offset=1");
}
 
2. MPEG4Writer中的file cache需要修改为64bit.
frameworks/av/include/media/stagefright/MPEG4Writer.h
这个Class MPEG4FileCacheWriter中的Define.
int seek(off_t offset, int refpos);
修改为:
int seek(off64_t offset, int refpos);
frameworks/av/media/libstagefright/MPEG4Writer.cpp
int MPEG4FileCacheWriter::seek(off_t offset,int refpos)
修改为:
int MPEG4FileCacheWriter::seek(off64_t offset,int refpos)
 
3. 如果想把录像文件的大小限制在4GB以内的话,还需要进行下面的修改:
frameworks/av/media/libstagefright/MPEG4Writer.cpp
static const int64_t kMax32BitFileSize = 0x007fffffffLL;
=>
static const int64_t kMax32BitFileSize = 0x00ffffffffLL;
把下面这个if (mUse32BitOffset) 条件注释掉就OK了。
status_t MPEG4Writer::start(MetaData *param){
   ... ...
    //if (mUse32BitOffset) {
        // Implicit 32 bit file size limit
        if (mMaxFileSizeLimitBytes == 0) {
            mMaxFileSizeLimitBytes = kMax32BitFileSize;
        }
        // If file size is set to be larger than the 32 bit file
        // size limit, treat it as an error.
        if (mMaxFileSizeLimitBytes > kMax32BitFileSize) {
            ALOGW("32-bit file size limit (%lld bytes) too big. "
                 "It is changed to %lld bytes",
                mMaxFileSizeLimitBytes, kMax32BitFileSize);
            mMaxFileSizeLimitBytes = kMax32BitFileSize;
        }
 

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,