Content Authoring with MP4Box

用mp4box来hint文件的操作很简单

hint:
mp4box filename -hint

反hint则是:
mp4box filename -unhint

查看track:

mp4box filename -info


Content Authoring with MP4Box

原文链接:http://gpac.sourceforge.net/doc_mp4box.php

This page is dedicated to MP4Box, the GPAC command line swiss army knife. You will find here a detailed documentation on major switches of MP4Box. Not all tools are documented, so do not hesitate to look at the MP4Box usage by typing MP4Box -h.

General Considerations


This document may refer to IsoMedia files. IsoMedia is a generic name for all formats based on the MPEG-4 Part 12 specification: MP4, 3GP and MJ2K files. Support for MJ2K files has not be tested in GPAC yet.

As of version 0.2.4, MP4Box performs in-place rewrite of IsoMedia files (the input file is overwritten). You can change this behaviour by using the -out Filename option.
For older versions, when MP4Box is used to modify an existing IsoMedia file, the original file (for example AFILE.mp4) is NOT overwritten, the resulting file is stored in out_AFILE.mp4. To specify another name for the resulting file, use the -out Filename option.

As of version 0.2.4, MP4Box always stores the file with 0.5 second interleaving and meta-data at the begining, making it suitable for HTTP streaming.

MP4Box usually generates a temporary file when creating a new IsoMedia file. The location of this temporary file is OS-dependent, and it may happen that the drive/partition the temporary file is created on has not enough space. In such an event, you may specify the temporary file location with the -tmp path_to_dir option.

MP4Box does NOT perform audio/video/image transcoding (re-encoding media tracks to a different coded format). If you need to transcode content, you will need other tools.

As of version 0.2.2, you don't need to follow any specific option ordering at prompt.

Please be aware that this page documents the latest version of MP4Box and may therefore give details on options available only on GPAC CVS. If your version of MP4Box does not support an option please upgrade.

File conversion

MP4Box can convert the following files into compliant IsoMedia files:
  • RAW Formats and extensions:
  • MPEG-4 Video (.cmp .m4v)
  • MPEG-4 Audio ADTS-AAC (.aac) - ADIF or RAW formats not supported
  • MPEG-1/2 Audio (.mp3)
  • JPEG and PNG Images (.jpg .jpeg .m4v)
  • H263 Video (.263 .h263)
  • AVC/H264 Video (.264 .h264, .26l .h26l)
  • AMR and AMR-WideBand Speech (.amr .awb)
  • EVRC Speech (.evc)
  • SMV Speech (.smv)
  • NHNT (.media .info .nhnt)
  • AV Containers and extensions:
  • AVI (.avi) - Only MPEG-4 video and MP3 audio supported at the current time.
  • MPEG-PS (.mpg .mpeg .vob) - Only MPEG-1/2 video and MPEG-1/2 audio supported at the current time.
  • QCP (.qcp)
  • XIPH OGG (.ogg) - EXPERIMENTAL and not relevant to any IsoMedia-based standards. Only Vorbis audio and Theora video supported.
  • IsoMedia files (no extension checking)
  • Text formats and extensions:
  • SRT Subtitles (.srt)
  • SUB Subtitles (.sub)
The conversion syntax is MP4Box -add inputFile destinationFile. This option is used to import media from several sources. You can specify up to 20 -add to MP4Box. This process will create the destination file if not existing, and add the track(s) to it. If you wish to erase the destination file, just add the -new option
Note: You can also use this option to merge tracks from different IsoMedia files.

Input file track selection
To select a desired media track, the following syntax is used:
  • -add inputFile#video: adds the first video track in inputFile. DOES NOT WORK for IsoMedia files.
  • -add inputFile#audio: adds the first audio track in inputFile. DOES NOT WORK for IsoMedia files.
  • -add inputFile#trackID=ID or -add inputFile#ID: adds the specified track. For IsoMedia files, ID is the track ID. For other media files, ID is the value indicated by MP4Box -info inputFile.

MP4Box can import a desired amount of the input file rather than the whole file. To do this, use the syntax -add inputFile%N, where N is the number of seconds you wish to import from input. MP4Box cannot start importing from a random point in the input, it always import from the begining.

When using -add option, MP4Box will automatically create default BIFS and OD tracks to make the resulting file compliant with the ISMA 1.0 standard if possible. If the destination file extension is .3gp or .3g2, MP4Box will automatically make the file 3GP(2) compliant. This means that MP4Box will always remove any systems tracks when using -add, you may prevent this by using the -keepsys option.

Note on text import : When importing SRT or SUB files, MP4Box will choose default layout options to make the subtitle appear at the bottom of the video. You SHOULD NOT import such files before any video track is added to the destination file, otherwise the results will be likelly not be usefull (default SRT/SUB importing uses default serif font, fontSize 18 and display size 400x60). For more details on 3GPP timed text, please go here.

Import Options
There are several media-specific options which can be used when importing media. To know which options are supported for non-IsoMedia files, use the -info option for the desired media track, for example MP4Box -info 2 file.mpg.

-sbr : forces importing the AAC-ADTS file as AAC SBR (aka HE-AAC, aka aacPlus) with backward compatible signaling (eg non SBR aware decoders should play the file).
-sbrx : forces importing the AAC-ADTS file as AAC SBR (aka HE-AAC, aka aacPlus) with non-backward compatible signaling (eg non SBR aware decoders should NOT play the file).
Note : MP4Box CANNOT detect whether AAC input is regular or SBR AAC, so you must use one fo these options if you want to import AAC SBR files.

-dref : MP4Box can import media data without copying it, this is called data referencing. The resulting file only contains the meta-data of the presentation (frame sizes, timing, etc...) and references media data in the original file. This is extremely usefull when developping content, since importing and storage of the MP4 file is much faster and the resulting file much smaller. Use the -dref option to enable data referencing.
NOTE : Data referencing may fail on some files because it requires the framed data (eg an IsoMedia sample) to be continuous in the original file, which is not always the case depending on the original interleaving or bitstream format.

-nodrop : Some AVI files may have non-coded frames (n-VOPs) introduced by the encoder. By default, MP4Box will discard these frames, hence producing a variable frame-rate visual stream. You can force MP4Box to keep constant frame-rate by specifying -nodrop while importing the AVI file.

-packed: When importing raw MPEG-4 Video, forces considering the bitstream as the dump of an AVI Packed Bitstream (removes all n-vops and import as constant FPS).

-fps FrameRate : If possible, will override the original video frame rate. This option is also used when importing SUB text files to specify the SUB framerate. Framerate is a double-precision number.

-mpeg4 : This option forces MPEG-4 stream descriptions for formats having several description syntax available - only possible for QCELP, EVRC and SMV audio.

-agg N : Aggregates N audio frames in an IsoMedia sample. This option is only valid for some 3GP(2) audio formats (AMR, QCELP, EVRC and SMV audio). The maximum acceptable value is 15.

When importing several tracks/sources, all options will be applied if relevant to each source.

Note on OGG Support : MP4Box can import OGG files containing either Vorbis audio or Theora video. This feature is experimental and support for these media formats in IsoMedia files is NOT STANDARDIZED anywhere. This should only be used for development and R&D purposes, and you must be aware that files created this way may be unusable, even with future versions of GPAC.

File Splitting and Concatenation

MP4Box can split IsoMedia files by size, duration or extract a given part of the file to new IsoMedia file(s). This process requires that at most one track in the input file has non random-access points (typically one video track at most). This process will also ignore all MPEG-4 Systems tracks and hint tracks, but will attempt to split private media tracks.
Note : The input file must have enough random access points in order to be splitted. This may not be the case with some video files where only the very first sample of the video track is a key frame (many 3GP files with H263 video are recorded that way). In order to split such files you will have to use a real video editor and re-encode the content.

-split time_in_seconds : splits the input file in a sequence of files lasting at most the specified time. Depending on random access distribution in the file (sync samples), the duration of the resulting files may be less than specified.

-splits size_in_kb : splits the input file in a sequence of files of maximum specified size. Depending on random access distribution in the file (sync samples), the size of the resulting files may be less than specified.

-splitx StartTime:EndTime : extracts a subfile from the input file. StartTime and EndTime are specified in seconds. Depending on random access distribution in the file (sync samples), the startTime will be adjusted to the previous random access time in the file.

-cat a_file : concatenates a_file to input file (samples are added to existing tracks rather than added to new tracks). The usage is the same as -add, you may use non IsoMedia input files (for example, AVIs or MPEGs) and concatenates them directly into a new IsoMedia file. This process will remove all MPEG-4 systems tracks from the final file and make it compliant to ISMA or 3GP just like the -add process. You can instruct MP4Box not to remove MPEG-4 systems tracks by specifying -keepsys.

General File operations

MP4Box can rewrite IsoMedia files for distribution purposes - these options may also be used while converting files.
-isma: converts file to ISMA 1.0 specification. This is extremely usefull since most MPEG-4 players only understand ISMA-like content. All systems information and tracks numbering are rewritten to comply to the specification. WARNING: some media tracks may be removed.

-3gp : converts to 3GPP specification. This will remove all MPEG-4 Systems information, leaving only the audio/video/text media tracks supported by 3GPP. WARNING: some media tracks may be removed.

-nosys : removes all MPEG-4 systems tracks and keeps an empty InitialObjectDescriptor will be left in the file for MPEG-4 Level@Profile indications.

-inter Duration : interleaves media data in chunks of desired duration (in seconds). This is usefull to optimize the file for HTTP/FTP streaming. All meta data are placed first in the file, allowing a player to start playback while downloading the content. By default MP4Box always stores files with half a second interleaving. Specifying a 0 interleaving time will result in the file being stored without interleaving, with all meta-data placed at beginning of the file.

-flat : forces flat storage of the file: media data placed at the begining of the file without interleaving, and meta-data at the end of the file. When used with -add to create a new file, no temporary file is created (faster storage).

-rem trackID : removes given track from file.

-cprt string : adds copyright to file.

-chap chap_file : adds chapter information located in chap_file to the destination file. Chapter extensions have been introduced by Nero and are NOT standard extensions of IsoMedia file format, don't be surprised if some players don't understand them.
The following syntaxes are supported in the chapter text file, with one chapter entry per line:
ZoomPlayer chapter files : AddChapter(nb_frames,chapter name), AddChapterBySeconds(nb_sec,chapter name) and AddChapterByTime(h,m,s,chapter name). One chapter entry per line.
Time codes : h:m:s name, h:m:s:ms name and h:m:s.ms name. One chapter entry per line.
SMPTE codes : h:m:s;nb_f/fps name and h:m:s;nb_f name with nb_f the number of frames and fps the framerate. One chapter entry per line.
Common syntax : CHAPTERX=h:m:s[:ms or .ms] on one line and CHAPTERXNAME=name on the other - the order is not important but chapter lines MUST be declared sequencially (same X value expected for 2 consecutive lines).

Some existing MP4 files may use MPEG-4 Visual tracks with B-Frames in an improper way. There is currently no automatic cleaning of such files in MP4Box, but reimporting the track will solve the problem. To do this:
  • MP4Box -avi trackID file.mp4: exports track to avi (raw MPEG-4 video also possible).
  • MP4Box -import file.avi dest.mp4: converts avi into MP4 and handles B-Frame correct import (packed bitstreams, n-Vops).

    File hinting

IsoMedia File Hinting consists in creating special tracks in the file that contain transport protocol specific information and optionally multiplexing information. These tracks are then used by the server to create the actual packets being sent over the network, in other words they provide the server 'hints' regarding packet building, hence their names: Hint Tracks.
MP4Box can generate these hint tracks for the RTP protocol (the most widely used protocol for multimedia streaming). The resulting file can then be streamed to clients with any streaming server understanding the IsoMedia file format and hint tracks, such as Apple's QTSS/DSS servers.

-hint : hints the given file for RTP/RTSP
-mtu : specifies the desired maximum packet size, or MTU (Maximum Transmission Unit). This must be choosen carefully: specifying too large packets will result in undesired packet fragmentation at lower transport layers. The default size when hinting is 1500 bytes (Ethernet MTU).
-multi [maxptime] : enables sample concatenation in a single RTP packet for payload formats supporting it. maxptime is an optional integer specifying the maximum packet duration in milliseconds, used for some audio payloads. Its default value is 100 ms.
-copy : forces hinted data to be copied to the hint track. This speeds up packet building at server side but takes much more space on disk.
-tight : performs sample-based interleaving of media tracks and hint tracks. This should reduce disk seeks at server side (depending on server implementation) but results in a bigger file.
-mpeg4 : forces usage of MPEG-4 Generic Payload whenever possible.
-ocr : forces all media tracks in the file to be served synchronized. This is needed because most streaming servers don't support desynchronized tracks in a single file. Be extremelly carefull when designing MPEG-4 interactive presentations for streaming since you will have to take care of the streaming server capabilities... MP4Box generates warnings when the file timeline can be ambiguously interpreted by the server.
-iod : prevents ISMA-like IOD generation in SDP. MP4Box automatically detects ambiguous (ISMA/non-ISMA) files but nobody's perfect. This shouldn't be used with -isma option.
-sdp_ex string : adds the given text to the movie SDP information ( -sdp_ex "a=x-test: an sdp test") or to a track ( -sdp_ex "N:a=x-test", where N is the hint track or its base track ID). This will take care of SDP line ordering. WARNING: You cannot add anything to SDP, please refer to RFC2327 for more info.
-unhint : removes all hint tracks and SDP information from file. This can be usefull since MP4Box doesn't remove any existing hint tracks when hinting the file.

MP4Box always detects the best payload possible and when not found gets back to MPEG-4 Generic payload. The configuration of the MPEG-4 Generic payload is quite complex, so MP4Box always computes the most suitable configuration for you. However there are more hinting options available to configure the MPEG-4 Generic RTP payload (type -h hint for help) in case you need to transport MPEG-4 specific informations.

Examples:
  • Prepare any mp4 for ISMA streaming: MP4Box -isma -hint myfile.mp4
  • Prepare an mp4 optimized for server: MP4Box -hint -copy -tight myfile.mp4
  • Prepare a complex mp4 with BIFS for streaming: MP4Box -ocr -iod -hint myfile.mp4
  • Prepare any 3GP/MP4 for safe streaming: MP4Box -nosys -hint myfile.3gp
Q&As:
  • Can I stream MP4 files created with MPEG4IP's mp4creator to GPAC?
    It depends. mp4creator hints mp3 audio with MPA or MPA-robust payload formats, specific to mp3 streams. MPA-robust is not supported in GPAC and is not on the list of priorities, we strongly prefer working with RFC3640 payload for MPEG-4 streams. However if no MPA-robust payload is used, both players and hinters should interoperate.
  • Can I stream MP4 files created with MP4Box to MPEG4IP player?
    It depends. MPEG4IP works with ISMA / plain AV files, therefore you should first convert your file to ISMA before hinting.
  • Can I stream complex MPEG-4 presentations created with MP4Box to any player ???
    Yes and no. GPAC uses RFC3640 to stream MPEG-4 systems information, and most players don't accept that (they usually use their own format). Moreover RTSP servers as known today only understand simple synchronized presentations, and most MPEG-4 presentations have too complex timing for servers to handle. If you need to know more about that join us in our forum.

    File Dumping and information

    MP4Box has many dump functionalities, from simple track listing to more complete reporting of special tracks
-info : prints some file information. File can be an IsoMedia file or any file supported by MP4Box for import.
-info TrackID : prints extended track information for IsoMedia files, and supported import flags for other files.
-diso : creates XML image of the file structure.
-drtp : creates XML image of all hint tracks samples of a hinted mp4 file.
-sdp : creates SDP file associated with a hinted mp4 file.
-ttxt : converts input subtitle (SRT, SUB) to GPAC TTXT format.
-ttxt TrackID : dumps text track to TTXT XML format.
-srt : converts input subtitle (TTXT, SUB) to SRT format.
-srt TrackID : dumps text track to SRT format.
-std : dumps to stdout instead of file.

Media track Extraction

MP4Box can extract media tracks in a variety of formats:
-raw TrackID : extracts track to its native format.
-raws TrackID : extracts each track sample to a file. To extract a single sample, use -raws TrackID:N
-avi TrackID : extracts visual track in avi format (MPEG-4 Visual and AVC/H264 supported).
-nhnt TrackID : extracts track in NHNT format.
-qcp TrackID : same as -raw but defaults to QCP file for EVRC/SMV.
-aviraw track : extracts avi track to its native format. track can be one of video, audio, audioN N being the number of the audio track.
-single TrackID : extracts track in a new MP4 with a single track.

MPEG-4 Systems, VRML and X3D Handling

MP4Box can be used to encode and decode MPEG-4 Scene Description. It may also be used to convert to and from the various textual format: BT, XMT-A, WRL (VRML97) and X3D in XML or VRML format. These conversions will not always work since these standards do not use the same set of nodes.
-mp4 : specifies input file is to be encoded. Supports .bt (BT), .xmt (XMT-A) , .wrl (VRML97) and .swf (Flash) input. For more details on flash input, try MP4Box -h swf. For more details on BT/XMT-A, go here.
-def : encodes DEF/USE nodes and routes names as strings. This is usefull when developping content otherwise the decoded scene becomes quickly messy.
-ms : specifies the media source to check for track importing. This is needed when no MuxInfo is present in the BT file, although this is not recommended. By default, MP4Box looks for tracks in MYFILE.mp4 when encoding MYFILE.bt
-bt : dumps scene in a BT file.
-xmt : dumps scene in an XMT-A file.
-wrl : dumps scene into VRML97 format - unknown/incompatible nodes are removed.
-x3d : dumps scene into X3D/XML format - unknown/incompatible nodes are removed.
-x3dv : dumps scene into X3D/text format - - unknown/incompatible nodes are removed.

ISMA Encryption and description

MP4Box supports ISMA E&A specification, better known as ISMACryp.
-crypt drm_file : encrypts IsoMedia file according to rules specified drm_file. More info on this is available here.
-decrypt drm_file : decrypts IsoMedia file. drm_file is optional if the keys are stored within the file. More info on this is available here.

Misc

-nodes : prints list of MPEG-4 nodes supported in this MP4Box build.
-node NodeName : prints MPEG-4 node syntax: fields, their type, event type, default value and quantization info if any. Note this works only for nodes supported in the current built.
-xnodes : prints list of X3D nodes supported in this MP4Box build.
-node NodeName : prints X3D node syntax: fields, their type, event type and default value. Note this works only for nodes supported in the current built.
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
The OpenStack Foundation supported the creation of this book with plane tickets to Austin, lodging (including one adventurous evening without power after a windstorm), and delicious food. For about USD $10,000, we could collaborate intensively for a week in the same room at the Rackspace Austin office. The authors are all members of the OpenStack Foundation, which you can join. Go to the Foundation web site. We want to acknowledge our excellent host Rackers at Rackspace in Austin: Emma Richards of Rackspace Guest Relations took excellent care of our lunch orders and even set aside a pile of sticky notes that had fallen off the walls. Betsy Hagemeier, a Fanatical Executive Assistant, took care of a room reshuffle and helped us settle in for the week. The Real Estate team at Rackspace in Austin, also known as “The Victors,” were super responsive. Adam Powell in Racker IT supplied us with bandwidth each day and second monitors for those of us needing more screens. On Wednesday night we had a fun happy hour with the Austin OpenStack Meetup group and Racker Katie Schmidt took great care of our group. We also had some excellent input from outside of the room: Tim Bell from CERN gave us feedback on the outline before we started and reviewed it mid-week. Sébastien Han has written excellent blogs and generously gave his permission for re-use. Oisin Feeley read it, made some edits, and provided emailed feedback right when we asked. Inside the book sprint room with us each day was our book sprint facilitator Adam Hyde. Without his tireless support and encouragement, we would have thought a book of this scope was impossible in five days. Adam has proven the book sprint method effectively again and again. He creates both tools and faith in collaborative authoring at www.booksprints.net. We couldn’t have pulled it off without so much supportive help and encouragement.
07-23
OpenStack基金会为这本书的创作提供了机票前往奥斯汀、住宿(包括一次在一场风暴后没有电力的冒险夜晚)和美味的食物。花费约1万美元,我们可以在Rackspace奥斯汀办公室的同一个房间里密集合作一周。作者们都是OpenStack基金会的成员,您也可以加入。请访问基金会网站。 我们要感谢我们在奥斯汀的卓越主机Rackspace: Rackspace客户关系部的Emma Richards非常照顾我们的午餐订单,甚至为我们留下了一堆掉落的便签纸。 Fanatical行政助理Betsy Hagemeier负责房间调整,并帮助我们安顿下来。 Rackspace奥斯汀的房地产团队,也被称为“胜利者”,非常负责任。 Racker IT的Adam Powell每天为我们提供带宽,并为那些需要更多屏幕的人提供了第二个显示器。 周三晚上,我们与奥斯汀OpenStack Meetup小组一起度过了愉快的欢乐时光,Racker Katie Schmidt非常照顾我们的团队。 我们还得到了其他人的优秀意见: 来自CERN的Tim Bell在我们开始前对大纲提供了反馈,并在中途进行了审查。 Sébastien Han撰写了优秀的博客,并慷慨地允许我们重新使用。 Oisin Feeley阅读了书稿,做了一些编辑,并在我们提问时立即提供了电子邮件反馈。 每天与我们一起进行书稿的房间里有我们的书稿会facilitator Adam Hyde。没有他不知疲倦的支持和鼓励,我们可能会认为在五天内完成这样一本书是不可能的。Adam一次又一次地证明了书稿会方法的有效性。他在www.booksprints.net上创建了协作创作的工具和信念。 没有这么多支持和鼓励,我们无法完成这本书。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值