為了要各方面測試Encoder和Decoder,所以常需要製作特別的mp4
今天特別把好用的tool整理一下
資料主要參考:
http://idaiwan.pixnet.net/blog/post/26310277-%E4%BD%BF%E7%94%A8-mp4box-%E5%88%86%E5%89%B2%E8%A6%96%E8%A8%8A%E6%A0%BC%E5%BC%8F%E7%82%BA-h264%EF%BC%88avc%EF%BC%89%E7%9A%84-flv-%E6%AA%94
使用的工具是 mp4box
是在window下執行的exe檔,然後下command去操作
(我安裝完後,MP4Box.exe在C:\Program Files\GPAC下)
例如要將一個音訊和一個視訊包在同一個mp4裡面可以下
MP4Box.exe -add video.264 -add audio.aac -fps 25.03 output.mp4
可用
-fps 來指定 frame rate (我曾經成功製作出1080p 60fps的影片,其實就是設定time stamp而已)
也可以切割特定時間的影片
MP4Box.exe -splitx 9:31.5 output.mp4
也可用它來看mp4的資訊MP4Box.exe -info file.mp4
* Movie Info *
Timescale 600 - Duration 00:04:03.583
Fragmented File no - 2 track(s)
File Brand isom - version 1
Created: GMT Wed Jul 27 04:44:43 2011
File has root IOD
Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
Visual PL: AVC/H264 Profile (0x15)
Audio PL: No audio capability required (0xff)
No streams included in root OD
Track # 1 Info - TrackID 1 - TimeScale 24000 - Duration 00:04:03.576
Media Info: Language "Undetermined" - Type "vide:avc1" - 5840 samples
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 720 x 480 - Profile High @ Level 4.1
NAL Unit length bits: 32
Pixel Aspect Ratio 1:1 - Indicated track size 720 x 480
Self-synchronized
Track # 2 Info - TrackID 2 - TimeScale 48000 - Duration 00:04:03.584
Media Info: Language "Undetermined" - Type "soun:ac-3" - 7612 samples
AC3 stream - Sample Rate 48000 - 2 channel(s) 16 bits per samples
然後可依據這個資訊抽出你想要的track
若要提取 track 1 就這樣下
MP4Box.exe -raw 1 file.mp4 Extracting MPEG-4 AVC-H264 stream to h264
提出來就是h.264檔案了
總之提法就是: MP4Box.exe -raw track (#number) (input filename)
track2的提法
R:\>mp4box -raw 2 file.mp4 Extracting AC3 Audio
這邊就會提出track2的aac音訊檔