MP4V2版MP4文件生成 - 内存中的H264帧和AAC帧

ffmpeg保存MP4参见:https://blog.csdn.net/xinxinsky/article/details/88531524,代码:https://gitee.com/careye_open_source_platform_group/MP4MuxerTest/repository/archive/master.zip

从IPC采集H264帧和AAC帧,然后保存为MP4文件,直接上代码:

#include <mp4v2/mp4v2.h>

#include <assert.h>
#include <errno.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <time.h> 
#include <sys/time.h>
#include <sys/stat.h>
#include <unistd.h>

const unsigned char RL_NALU_TYPE_NONE = -1;
const unsigned char RL_NALU_TYPE_SLICE = 0x01;
const unsigned char RL_NALU_TYPE_IDR = 0x05;
const unsigned char RL_NALU_TYPE_SEI = 0x06;
const unsigned char RL_NALU_TYPE_SPS = 0x07;
const unsigned char RL_NALU_TYPE_PPS = 0x08;
const unsigned char RL_NALU_TYPE_MASK = 0x1f;

//视频或者音画同步的主要参数是duration, 公式可以是 (当前帧录制时间-上一针录制时间)*90000/1000;
const int timeScale = 90000;

inline bool is_frame_delimeter(const uint8_t *data, int& len) {
    len = (0x00 == data[0] && 0x00 == data[1] && 0x01 == data[2]) ? 3 : 
        ((0x00 == data[0] && 0x00 == data[1] && 0x00 == data[2] && 0x01 == data[3]) ? 4 : 0);
    return(0 != len);
}

int CreateMP4File(MP4FileHandle& pHandle, const char *strFileName) {
    pHandle = MP4Create(strFileName, 0);
    if(pHandle == 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值