Bento4 SDK documentation
Axiomatic Systems, LLC
2008
Bento4 SDK Documentation – 2/14
Table of Contents
1 Why use Bento4? ....................................................................................................................................................................3
1.1 Overview (README.txt) ..............................................................................................................................................3
1.2 Typical Bento4 use cases ...............................................................................................................................................3
1.2.1 Reading an MP4 file in a player ............................................................................................................................3
1.2.2 Writing an MP4 file from a source ........................................................................................................................4
1.2.3 Encrypting a file and adding content protection information ................................................................................4
1.2.4 Decrypting a file sample per sample in a player....................................................................................................4
1.2.5 Reading hint tracks of an MP4 file in an RTSP/RTP server .................................................................................5
1.3 Downloading Bento4......................................................................................................................................................5
1.3.1 Releases (downloadable from SourceForge.net) ...................................................................................................5
1.3.2 Bleeding edge (svn access)....................................................................................................................................5
1.4 Dependencies and requirements .....................................................................................................................................5
2 Overview of source tree ..........................................................................................................................................................5
2.1 High-level view of the source tree .................................................................................................................................5
2.2 Build directory................................................................................................................................................................6
2.3 Documents directory ......................................................................................................................................................6
2.4 Source directory .............................................................................................................................................................6
2.4.1 Library sources ......................................................................................................................................................6
2.4.2 Application sources ...............................................................................................................................................6
3 Building Bento4 ......................................................................................................................................................................7
3.1 Overview and build tools ...............................................................................................................................................7
3.1.1 Organization ..........................................................................................................................................................7
3.1.2 Microsoft Visual Studio.........................................................................................................................................7
3.1.3 SCons ....................................................................................................................................................................7
3.1.4 make.......................................................................................................................................................................7
3.1.5 XCode (Mac OS X only) .......................................................................................................................................7
3.2 Platform specific instructions.........................................................................................................................................8
3.2.1 Windows desktop (x86-microsoft-win32-vs2005) ................................................................................................8
3.2.2 Windows CE (arm-microsoft-wince-vs2005)........................................................................................................8
3.2.3 Cygwin (x86-unknown-cygwin)............................................................................................................................8
3.2.4 Linux x86 (x86-unknown-linux) ...........................................................................................................................8
3.2.5 Apple Mac OS X ...................................................................................................................................................8
4 The Bento4 API ......................................................................................................................................................................8
5 Reading a file: a simple walk-through ....................................................................................................................................9
6 Writing a file: a simple walk-through .....................................................................................................................................9
7 Example Applications .............................................................................................................................................................9
7.1 Aac2Mp4 ........................................................................................................................................................................9
7.2 Mp42Aac ......................................................................................................................................................................10
7.3 Mp4Edit........................................................................................................................................................................10
7.4 Mp4Encrypt..................................................................................................................................................................10
7.5 Mp4Extract...................................................................................................................................................................11
7.6 Mp4Decrypt..................................................................................................................................................................11
7.7 Mp4Dump ....................................................................................................................................................................12
7.8 Mp4Info........................................................................................................................................................................12
7.9 Mp4RtpHintInfo ...........................................................................................................................................................12
7.10 Mp4Tag ......................................................................................................................................................................13
8 Copyright and Licensing .......................................................................................................................................................13
8.1 Copyright......................................................................................................................................................................13
8.2 LICENSE.txt ................................................................................................................................................................13
9 References .............................................................................................................................................................................14
Bento4 SDK Documentation – 3/14
1 WHY USE BENTO4?
1.1 Overview (README.txt)
Bento4/AP4 is a C++ class library designed to read and write ISO-MP4 files. This format is defined in
[ISO/IEC 14496]. The format is a derivative of the Apple Quicktime file format. Because of that,
Bento4 can be used to read and write a number of Quicktime files as well, even though some
Quicktime specific features are not supported. In addition, Bento4 supports a number of extensions as
defined in various other specifications. This includes some support for ISMA Encrytion and Decryption
as defined in the [ISMA E&A] specification, OMA 2.0 DCF/PDCF Encryption and Decryption as
defined in the [OMA 2.0 DCF/PDCF] specification, and iTunes compatible metadata. The SDK
includes a number of command line tools, built using the class library, that serve as general purpose
tools as well as examples of how to use the API.
The SDK is designed to be cross-platform. The code is very portable; it can be compiled with any
sufficiently modern C++ compiler. The code does not rely on any external library; all the code
necessary to compile the SDK and its tools is included in the standard distribution. The standard
distribution contains makefiles for unix-like operating systems, including Linux, project files for
Microsoft Visual Studio, and an XCode project for MacOS X. There is also support for building the
library with the SCons build system.
You can find out more about the license in LICENSE.txt (see Section 8). You can also read some of the
API documentation produced from the source code comments using Doxygen. The doxygen output is
available as a windows CHM file in Bento4.chm, and a set of HTML pages zipped together in Bento4-
HTML.zip (to start, open the file named index.html with an HTML browser).
1.2 Typical Bento4 use cases
Here are some typical use cases for the Bento4 library.
1.2.1 Reading an MP4 file in a player
Bento4 is able to take an MP4 file as an input and extract audio and video samples for the relevant
decoder to process as well as the information needed to initialize the decoders.
Bento4
MP4 file
audio samples
video samples
Audio
decoder
Video
decoder
decompressed
audio samples
decompressed
video samples
C
O
M
P
O
S
E
R
output
player
Bento4 SDK Documentation – 4/14
1.2.2 Writing an MP4 file from a source
Bento4 is able to package an MP4 file from an encoder output. Below is an example of a complete
setup.
1.2.3 Encrypting a file and adding content protection information
Bento4 is able to encrypt a cleartext MP4 file given a set of keys, as well as to package additional
information such as content protection data.
1.2.4 Decrypting a file sample per sample in a player
Given the set of relevant keys, Bento4 can decrypt the content of an encrypted MP4 file sample by
sample for the decoder to process.
Bento4
MP4 file
AAC samples
AAC
encoder
PCM audio
microphone
Bento4
Cleartext
MP4 file
Content
protection info
Key(s)
Protected
MP4 file
player
Bento4
Decoder
Cleartext
samples
Decoded
samples
Encrypted
MP4 file
Key(s)
Bento4 SDK Documentation – 5/14
1.2.5 Reading hint tracks of an MP4 file in an RTSP/RTP server
From a hinted MP4 file, Bento4 is able to extract SDP information to be sent for the RTSP DESCRIBE
response and RTP packets containing the media data (see [ISMA]).
1.3 Downloading Bento4
Bento4 and all relevant documentation are available for download from the following sources:
1.3.1 Releases (downloadable from SourceForge.net)
http://www.sourceforge.net/projects/bento4
1.3.2 Bleeding edge (svn access)
https://zebulon.bok.net/svn/Bento4/trunk
1.4 Dependencies and requirements
Bento4 is a standalone multi-platform project. It bears no source-level dependencies to any other
software package. See Section 3 for building instructions.
2 OVERVIEW OF SOURCE TREE
This section provides an overview of the main directories in the source tree.
2.1 High-level view of the source tree
The standard Bento4 distribution source tree unfolds as such:
− Build
− Makefiles
− Targets
− Tools
− Documents
− Source
− C++
− Apps
Bento4
Hinted
MP4 file
SDP information
RTP packets
- 1
- 2
- 3
前往页