mp4v2

** https://code.google.com/archive/p/mp4v2/ **
** https://mp4v2.org **

交叉编译

./configure --prefix=$INSTALL_PATH \
    --host=arm-none-linux-gnueabi \
    --build=i486-linux-gnu \
    --disable-option-checking \
    --enable-optimize \
    --disable-fvivibility \
    --disable-gch \
    --disable-largefile \
    --enable-util \
    --disable-cygmin-win32 \
    --disable-mingw-threads \
    --disable-dependency-tracking \
    --enable-shared=yes \
    --enable-static=no \
    --enable-fast-install=yes \
    --disable-libtool-lock \
    --with-gnu-ld

参考示例代码

int main(void)
{
    unsigned char sps_pps[14] = {0x67, 0x4d, 0x40, 0x1F, 0x96 ,0x54, 0x05, 0x01, 0xec, 0x80, 0x68, 0xce, 0x38, 0x80};
    char *p[4];
    p[0] = "isom";
    p[1] = "iso2";
    p[2] = "avc1";
    p[3] = "mp41";
    MP4FileHandle  file = MP4CreateEx("test.mp4", 0, 1, 1, "isom", 0x00000200, p, 4);
    
    if (file == MP4_INVALID_FILE_HANDLE) 
    {
        printf("open file fialed.\n"); 
        return; 
    }
    MP4SetTimeScale(file, 90000);
 
    MP4TrackId video = MP4AddH264VideoTrack(file, 90000, 90000/25, 640, 480, 
                                            0x4d, //sps[1] AVCProfileIndication 
                                            0x40, //sps[2] profile_compat 
                                            0x1f, //sps[3] AVCLevelIndication 
                                            3); // 4 bytes length before each NAL unit 
    if (video == MP4_INVALID_TRACK_ID) 
    { 
        printf("add video track failed.\n"); 
        return; 
    } 
    MP4SetVideoProfileLevel(file, 0x7F); 
 
    MP4TrackId audio = MP4AddAudioTrack(file, 16000, 1024, MP4_MPEG4_AUDIO_TYPE); 
    if (video == MP4_INVALID_TRACK_ID) 
    { 
        printf("add audio track failed.\n"); 
        return; 
    } 
    MP4SetAudioProfileLevel(file, 0x2); 
 
    while(mp4_read_h264_frame(fpMjpeg, buf, MP4_BUF_SIZE, &size) != -1)
    {
        buf[0] = ((size-4) & 0xff000000) >> 24;  
        buf[1] = ((size-4) & 0x00ff0000) >> 16;  
        buf[2] = ((size-4) & 0x0000ff00) >> 8;  
        buf[3] =  (size-4) & 0x000000ff; 
        MP4WriteSample(file, video, buf, size, MP4_INVALID_DURATION, 0, 1); 
    }
    
    while(-1 != mp4_read_aac_frame(fpPcm, buf, MP4_BUF_SIZE, &size))
    {
        MP4WriteSample(file, audio, buf, size, MP4_INVALID_DURATION, 0, 1); 
    }
    
    MP4AddH264SequenceParameterSet(file, video, sps_pps, 10);
    MP4AddH264PictureParameterSet(file, video, sps_pps+10, 4);
 
    MP4Close(file, 0);
    
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值