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 installlinux

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 音視頻的編碼算法等等基本知識;api

好比解析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

這兒有一些關鍵信息:ide

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結構解析流程,返回給用戶直接是一幀幀數據的方式; 
你只須要經過對應的接口~以幀的方式讀取處理便可;spa

相關文章
相關標籤/搜索