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;
        }
 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *