00.mp4v2工具的用法
1.交叉编译mp4v2库
# ./configure --prefix=/usr/local/mp4v2-2.0.0 --host=arm-hisiv300-linux
CC=arm-hisiv300-linux-gcc CXX=arm-hisiv300-linux-g++
#make
#make install
2.工具用法
./mp4info 20161024091151_180.MP4 ./mp4info version 2.0.0 20161024091151_180.MP4 : Track Type Info audio MPEG-4 AAC LC, 180.096 secs, 16 kbps, 8000 Hz video H264 Baseline@4.2, 180.000 secs, 8381 kbps, 1920x1080 @ 30.000000 fps ./mp4track 20161024091151_180.MP4 --list track[0] id=1 type = audio enabled = true inMovie = false inPreview = false layer = 0 alternateGroup = 0 volume = 1.0000 width = 0.00000000 height = 0.00000000 language = Undetermined handlerName = userDataName = <absent> track[1] id=2 type = video enabled = true inMovie = false inPreview = false layer = 0 alternateGroup = 0 volume = 0.0000 width = 1920.00000000 height = 1080.00000000 language = Undetermined handlerName = userDataName = <absent>
解析mp4的一些基本内容;比如长宽 和trackid 音视频的编码算法等等基本知识;
比如解析track 2 是一个视频通道,这个id从面mp4track 内容里面获取的.
./mp4trackdump 20161024091151_180.MP4 -t 2 ./mp4trackdump version 2.0.0 mp4file 20161024091151_180.MP4, track 2, samples 5400, timescale 90000 sampleId 1, size 203970 duration 3000 time 0 00:00:00.000 S sampleId 2, size 47935 duration 3000 time 3000 00:00:00.033 sampleId 3, size 62824 duration 3000 time 6000 00:00:00.066 sampleId 4, size 70342 duration 3000 time 9000 00:00:00.100 sampleId 5, size 20730 duration 3000 time 12000 00:00:00.133 sampleId 6, size 13241 duration 3000 time 15000 00:00:00.166 sampleId 7, size 6947 duration 3000 time 18000 00:00:00.200
这儿有一些关键信息:
sampleId 就是mp4 里面frame的索引;每个sampleId 对应一帧264的视频
size 就是frame的大小
duration 这个是给播放器使用的,播放器需要显示这一帧的时间就是 3000 / 90000 (timescale) 秒;这个视频是30帧的,就是1/30秒;后面的rtsp发流的时间撮也是根据这个时间来处理的;
后面的时间就是转化为秒为单位的时间;
./mp4trackdump 20161024091151_180.MP4 -t 1 ./mp4trackdump version 2.0.0 mp4file 20161024091151_180.MP4, track 1, samples 1403, timescale 8000 sampleId 1, size 249 duration 1024 time 0 00:00:00.000 S sampleId 2, size 286 duration 1024 time 1024 00:00:00.128 S sampleId 3, size 326 duration 1024 time 2048 00:00:00.256 S sampleId 4, size 320 duration 1024 time 3072 00:00:00.384 S sampleId 5, size 317 duration 1024 time 4096 00:00:00.512 S sampleId 6, size 316 duration 1024 time 5120 00:00:00.640 S sampleId 7, size 306 duration 1024 time 6144 00:00:00.768 S sampleId 8, size 301 duration 1024 time 7168 00:00:00.896 S sampleId 9, size 281 duration 1024 time 8192 00:00:01.024 S sampleId 10, size 288 duration 1024 time 9216 00:00:01.152 S
sampleId 就是mp4 里面aac frame的索引;每个sampleId 对应一阵aac的视频
size 就是frame的大小
duration 音频和视频一样,1024 就是在1024/8000 S时间内音频采样数据通过aac压缩算后得到的,其它音频算法压缩算法也基本一样;
后面的时间就是转化为秒为单位的时间;
mp4v2的api就是隐藏了复杂的mp4结构解析流程,返回给用户直接是一帧帧数据的方式;
你只需要通过对应的接口~以帧的方式读取处理即可;