// mvhd box typedef struct { u_char size[4]; // 大小 u_char name[4]; // 名字 u_char version[1]; // box版本,0或1,一般为0 u_char flags[3]; // 标识 u_char creation_time[4]; // 创建时间(相对于UTC时间1904-01-01零点的秒数) u_char modification_time[4]; // 修改时间 u_char timescale[4]; // 文件媒体在1秒时间内的刻度值,可以理解为1秒长度的时间单元数 u_char duration[4]; // 该track的时间长度,用duration和time scale值可以计算track时长 u_char rate[4]; // 推荐播放速率 u_char volume[2]; // 与rate类似,表示音量 u_char reserved[10]; // 保留位 u_char matrix[36]; // 视频变换矩阵 u_char PReview_time[4]; // 下面四个成员表示pre-defined u_char preview_duration[4]; u_char poster_time[4]; u_char selection_time[4]; u_char selection_duration[4]; u_char current_time[4]; u_char next_track_id[4]; // 下一个track使用的id号 } mp4_mvhd_atom;mvhd box的解析
// 读取mvhd boxintMp4Meta::mp4_read_mvhd_atom(int64_t atom_header_size, int64_t atom_data_size){ int64_t atom_size; uint32_t timescale; mp4_mvhd_atom *mvhd; mp4_mvhd64_atom mvhd64; if (sizeof(mp4_mvhd_atom) - 8 > (size_t)atom_data_size) return -1; // 读取mvhd box IOBufferReaderCopy(meta_reader, &mvhd64, sizeof(mp4_mvhd64_atom)); mvhd = (mp4_mvhd_atom*)&mvhd64; if (mvhd->version[0] == 0) { timescale = mp4_get_32value(mvhd->timescale); } else { // 64-bit duration timescale = mp4_get_32value(mvhd64.timescale); } // 读取timescale字段 this->timescale = timescale; atom_size = atom_header_size + atom_data_size; mvhd_atom.buffer = TSIOBufferCreate(); mvhd_atom.reader = TSIOBufferReaderAlloc(mvhd_atom.buffer); TSIOBufferCopy(mvhd_atom.buffer, meta_reader, atom_size, 0); mp4_meta_consume(atom_size); return 1;}
新闻热点
疑难解答