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 ==