Convert Figma logo to code with AI

axiomatic-systems logoBento4

Full-featured MP4 format, MPEG DASH, HLS, CMAF SDK and tools

2,050
488
2,050
544

Top Related Projects

A media packaging and development framework for VOD and Live DASH and HLS applications, supporting Common Encryption for Widevine and other DRM Systems.

2,835

GPAC Ultramedia OSS for Video Streaming & Next-Gen Multimedia Transcoding, Packaging & Delivery

47,343

Mirror of https://git.ffmpeg.org/ffmpeg.git

JavaScript player library / DASH & HLS client / MSE-EME player

14,428

VLC media player - All pull requests are ignored, please use MRs on https://code.videolan.org/videolan/vlc

1,210

A standalone library of the Fraunhofer FDK AAC code from Android.

Quick Overview

Bento4 is a C++ class library and tools designed to read and write ISO-MP4 files. It's a comprehensive toolkit for developers working with MP4 containers, providing support for various formats including MPEG DASH, HLS, and CMAF. Bento4 offers both a programming API and command-line tools for manipulating and inspecting MP4 files.

Pros

  • Extensive support for multiple streaming formats (DASH, HLS, CMAF)
  • Cross-platform compatibility (Windows, macOS, Linux, iOS, Android)
  • Actively maintained with regular updates
  • Provides both a C++ API and command-line tools

Cons

  • Steep learning curve for beginners due to the complexity of MP4 format
  • Limited documentation for some advanced features
  • Requires C++ knowledge for API usage
  • Large codebase may be overwhelming for simple tasks

Code Examples

  1. Opening an MP4 file and getting basic information:
#include "Ap4.h"

AP4_File* file = new AP4_File("input.mp4");
AP4_Movie* movie = file->GetMovie();
if (movie) {
    AP4_UI32 timescale = movie->GetTimeScale();
    AP4_UI64 duration = movie->GetDuration();
    printf("Timescale: %u, Duration: %llu\n", timescale, duration);
}
delete file;
  1. Adding a new track to an MP4 file:
AP4_Movie* movie = file->GetMovie();
AP4_Track* video_track = new AP4_Track(AP4_Track::TYPE_VIDEO,
                                       new AP4_AvcSampleDescription(1920, 1080, 24, 8, NULL, 0, NULL, 0),
                                       movie->GetTimeScale(),
                                       AP4_TRACK_DEFAULT_FLAGS);
movie->AddTrack(video_track);
  1. Writing an MP4 file:
AP4_ByteStream* output = NULL;
AP4_FileByteStream::Create("output.mp4", AP4_FileByteStream::STREAM_MODE_WRITE, output);
AP4_Movie* movie = new AP4_Movie(movie_time_scale);
AP4_File file(movie);
file.Write(*output);
output->Release();

Getting Started

To use Bento4 in your project:

  1. Clone the repository:

    git clone https://github.com/axiomatic-systems/Bento4.git
    
  2. Build the library and tools:

    cd Bento4
    mkdir cmakebuild
    cd cmakebuild
    cmake ..
    cmake --build .
    
  3. Include the necessary headers in your C++ project:

    #include "Ap4.h"
    
  4. Link against the Bento4 library when compiling your project.

Competitor Comparisons

A media packaging and development framework for VOD and Live DASH and HLS applications, supporting Common Encryption for Widevine and other DRM Systems.

Pros of Shaka Packager

  • More active development and frequent updates
  • Better support for modern streaming formats like DASH and HLS
  • Extensive documentation and examples for various use cases

Cons of Shaka Packager

  • Steeper learning curve for beginners
  • Limited support for older media formats
  • Larger codebase, potentially leading to longer build times

Code Comparison

Shaka Packager (C++):

PackagerOptions options;
options.output_media_info = true;
options.mpd_output = "output.mpd";
options.hls_master_playlist_output = "master.m3u8";
Packager packager;
packager.Initialize(options);

Bento4 (C++):

AP4_ByteStream* input;
AP4_FileByteStream::Create("input.mp4", AP4_FileByteStream::STREAM_MODE_READ, input);
AP4_File* file = new AP4_File(*input);
AP4_Movie* movie = file->GetMovie();

Both libraries offer powerful tools for media packaging and manipulation, but Shaka Packager is more focused on modern streaming formats, while Bento4 provides broader support for various MP4-based formats. Shaka Packager's code tends to be more high-level and abstracted, while Bento4 offers more granular control over file structures.

2,835

GPAC Ultramedia OSS for Video Streaming & Next-Gen Multimedia Transcoding, Packaging & Delivery

Pros of GPAC

  • More comprehensive multimedia framework with broader functionality
  • Active development with frequent updates and community support
  • Supports a wider range of multimedia formats and standards

Cons of GPAC

  • Steeper learning curve due to its extensive feature set
  • Potentially higher resource usage for simple tasks
  • Less focused on specific MP4-related operations compared to Bento4

Code Comparison

GPAC example (creating an MP4 file):

GF_ISOFile *movie = gf_isom_open("output.mp4", GF_ISOM_WRITE_EDIT, NULL);
GF_ISOSample *sample = gf_isom_sample_new();
gf_isom_add_sample(movie, 1, 1, sample);
gf_isom_close(movie);

Bento4 example (creating an MP4 file):

AP4_File* file = new AP4_File(AP4_DefaultAtomFactory::Instance);
AP4_Movie* movie = new AP4_Movie();
AP4_Track* track = new AP4_Track(AP4_Track::TYPE_VIDEO, 1000);
movie->AddTrack(track);
file->SetMovie(movie);

Both libraries offer powerful tools for working with multimedia files, particularly MP4 containers. GPAC provides a more comprehensive framework for various multimedia tasks, while Bento4 focuses more specifically on MP4-related operations. The choice between them depends on the specific requirements of your project and the level of complexity you're comfortable with.

47,343

Mirror of https://git.ffmpeg.org/ffmpeg.git

Pros of FFmpeg

  • Broader functionality, supporting a wide range of multimedia formats and operations
  • Larger community and more extensive documentation
  • More frequent updates and active development

Cons of FFmpeg

  • Steeper learning curve due to its complexity
  • Larger codebase, which may lead to longer compilation times
  • Can be overkill for projects focused solely on MP4 handling

Code Comparison

FFmpeg (video transcoding):

AVFormatContext *input_ctx = NULL;
avformat_open_input(&input_ctx, input_filename, NULL, NULL);
AVCodecContext *codec_ctx = avcodec_alloc_context3(NULL);
avcodec_parameters_to_context(codec_ctx, input_ctx->streams[0]->codecpar);

Bento4 (MP4 file manipulation):

AP4_File file(input_filename);
AP4_Movie* movie = file.GetMovie();
AP4_Track* track = movie->GetTrack(AP4_Track::TYPE_VIDEO);
AP4_SampleDescription* sample_description = track->GetSampleDescription(0);

While FFmpeg offers a more comprehensive set of tools for multimedia processing, Bento4 provides a more focused and potentially simpler solution for MP4-specific tasks. FFmpeg's code tends to be more complex due to its broader scope, while Bento4's API is more streamlined for MP4 operations.

JavaScript player library / DASH & HLS client / MSE-EME player

Pros of Shaka Player

  • Focuses on client-side streaming, offering a comprehensive JavaScript library for adaptive bitrate video playback
  • Supports a wide range of streaming formats, including DASH, HLS, and MSS
  • Provides extensive documentation and examples for easy integration

Cons of Shaka Player

  • Limited to client-side functionality, lacking server-side tools for content preparation
  • May have a steeper learning curve for developers new to streaming technologies
  • Requires additional tools or services for content packaging and encryption

Code Comparison

Shaka Player (JavaScript):

const video = document.getElementById('video');
const player = new shaka.Player(video);
player.load('https://example.com/video.mpd');

Bento4 (C++):

AP4_File file(input_filename);
AP4_Movie* movie = file.GetMovie();
AP4_Track* track = movie->GetTrack(AP4_Track::TYPE_VIDEO);

Summary

Shaka Player is a client-side streaming solution with broad format support and extensive documentation. It's ideal for web-based playback but lacks server-side tools. Bento4, on the other hand, is a comprehensive toolkit for both client and server-side operations, offering more flexibility in content preparation and manipulation. The choice between the two depends on specific project requirements and the desired level of control over the entire streaming pipeline.

14,428

VLC media player - All pull requests are ignored, please use MRs on https://code.videolan.org/videolan/vlc

Pros of VLC

  • Comprehensive media player with support for a wide range of formats and protocols
  • Large, active community and extensive documentation
  • Cross-platform compatibility (Windows, macOS, Linux, mobile)

Cons of VLC

  • Larger codebase and more complex architecture
  • Steeper learning curve for contributors
  • Heavier resource usage due to its full-featured nature

Code Comparison

VLC (media playback):

int libvlc_media_player_play(libvlc_media_player_t *p_mi)
{
    vlc_player_t *player = vlc_player_get(p_mi);
    return vlc_player_Start(player);
}

Bento4 (MP4 file parsing):

AP4_Result AP4_File::Parse()
{
    AP4_Result result = m_MovieReader->Parse(*this);
    if (AP4_FAILED(result)) return result;
    return AP4_SUCCESS;
}

VLC is a full-featured media player with extensive format support and cross-platform compatibility. It has a large community but a more complex codebase. Bento4 focuses on MP4 file manipulation, offering a simpler architecture for specific tasks. VLC's code example shows media playback initiation, while Bento4's demonstrates MP4 file parsing. Choose based on your project's scope and requirements.

1,210

A standalone library of the Fraunhofer FDK AAC code from Android.

Pros of fdk-aac

  • Specialized in AAC encoding and decoding
  • Highly optimized for performance and audio quality
  • Actively maintained with regular updates

Cons of fdk-aac

  • Limited to AAC codec, less versatile than Bento4
  • Smaller community and fewer resources compared to Bento4
  • More complex integration for non-audio-specific projects

Code Comparison

fdk-aac (encoding example):

HANDLE_AACENCODER hAacEncoder;
AACENC_ERROR err;

err = aacEncOpen(&hAacEncoder, 0, 2);
err = aacEncoder_SetParam(hAacEncoder, AACENC_AOT, AOT_AAC_LC);
err = aacEncoder_SetParam(hAacEncoder, AACENC_SAMPLERATE, 44100);

Bento4 (MP4 file creation example):

AP4_ByteStream* output = NULL;
AP4_FileByteStream::Create("output.mp4", AP4_FileByteStream::STREAM_MODE_WRITE, output);
AP4_Movie* movie = new AP4_Movie();
AP4_Track* track = new AP4_Track(AP4_Track::TYPE_AUDIO, sample_description, movie_time_scale, duration, 0, language, 0);
movie->AddTrack(track);

Both libraries serve different primary purposes. fdk-aac focuses on AAC codec operations, while Bento4 offers broader functionality for MP4 file manipulation and streaming protocols. The choice between them depends on the specific requirements of your project.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Bento4

CI

Bento4 is a C++ class library and tools designed to read and write ISO-MP4 files. This format is defined in international specifications ISO/IEC 14496-12, 14496-14 and 14496-15. The format is a derivative of the Apple Quicktime file format, so Bento4 can be used to read and write most Quicktime files as well.

Visit www.bento4.com for details

Features

A number of formats and features based on the ISO-MP4 format and related technologies are also supported, including:

  • MPEG DASH with fragmented MP4 files, as defined in ISO/IEC 23009-1
  • CMAF (Common Media Application Format) as defined in ISO/IEC 23000-19
  • MPEG Common Encryption (CENC) as specified in ISO/IEC 23001-7
  • PIFF (Protected Interoperable File Format): encrypted, fragmented MP4 format specified by Microsoft and used for encrypted HTTP Smooth Streaming.
  • Reading and writing 3GPP and iTunes-compatible metadata.
  • ISMA Encrytion and Decryption as defined in the ISMA E&A specification
  • OMA 2.0 and 2.1 DCF/PDCF Encryption and Decryption as defined in the OMA specifications.
  • ISO-MP4 files profiled as part of the 3GPP family of standards.
  • The UltraViolet (DECE) CFF (Common File Format).
  • Parsing and multiplexing of H.264 (AVC) video and AAC audio elementary streams
  • Support for multiple DRM systems that are compatible with MP4-formatted content (usually leveraging CENC Common Encryption), such as Marlin, PlayReady and Widevine.
  • Support for a wide range of codecs, including H.264 (AVC), H.265 (HEVC), AAC, AC-3, EC-3 (Dolby Digital Plus), AC-4, Dolby ATMOS, DTS, ALAC, and many more.

Design

The SDK is designed to be cross-platform. The code is very portable; it can be compiled with any sufficiently modern C++ compiler. The implementation does not rely on any external library. All the code necessary to compile the SDK and tools is included in the standard distribution. The standard distribution contains makefiles for unix-like operating systems, including Linux and Android, project files for Microsoft Visual Studio, and an XCode project for MacOS X and iOS. There is also support for building the library with the SCons build system.

License

The library is Open Source, with a dual-license model. You can find out more about the license on the About Page. The Developers Page contains specific information on where to obtain the source code and documentation. The Downloads Page contains the links to pre-built SDKs and tools that you can use to get started quickly.

Included Applications

The Bento4 SDK includes several command-line applications/tools that are built using the SDK API. These include:

app namedescription
mp4infodisplays high level info about an MP4 file, including all tracks and codec details
mp4dumpdisplays the entire atom/box structure of an MP4 file
mp4editadd/insert/remove/replace atom/box items of an MP4 file
mp4extractextracts an atom/box from an MP4 file
mp4encryptencrypts an MP4 file (multiple encryption schemes are supported)
mp4decryptdecrypts an MP4 file (multiple encryption schemes are supported)
mp4dcfpackagerencrypts a media file into an OMA DCF file
mp4compactconverts ‘stsz’ tables into ‘stz2′ tables to create more compact MP4 files
mp4fragmentcreates a fragmented MP4 file from a non-fragmented one or re-fragments an already-fragmented file
mp4splitsplits a fragmented MP4 file into discrete files
mp4tagshow/edit MP4 metadata (iTunes-style and others)
mp4muxmultiplexes one or more elementary streams (H264, AAC) into an MP4 file
mp42aacextract a raw AAC elementary stream from an MP4 file
mp42avcextract a raw AVC/H.264 elementary stream from an MP4 file
mp42hlsconverts an MP4 file to an HLS (HTTP Live Streaming) presentation, including the generation of the segments and .m3u8 playlist.
mp42tsconverts an MP4 file to an MPEG2-TS file.
mp4-dashcreates an MPEG DASH output from one or more MP4 files, including encryption.
mp4-dash-clonecreates a local clone of a remote or local MPEG DASH presentation, optionally encrypting the segments as they are cloned.

Building

The code can be built either by using the pre-configured IDE project files (Mac OSX, iOS and Windows), or compiled/cross-compiled using the SCons build system or CMake, or compiled using Make. Target platform specific build files and configurations are located under subdirectories Buid/Targets/xxxx where xxxx takes the form <architecture>-<vendor>-<os>. For example, the Linux x86 target specific files are located under Build/Targets/x86-unknown-linux. The XCode project files for Mac OSX are located under Build/Targets/universal-apple-macosx.

Mac OSX and iOS using XCode

Open the XCode project file Build/Targets/universal-apple-macosx/Bento4.xcodeproj and build

Windows using Visual Studio

Open the Visual Studio solution file Build/Targets/x86-microsoft-win32-vs2010/Bento4.sln and build

On Linux and other platforms, Using CMake

CMake can generate Makefiles, Xcode project files, or Visual Studios project files.

CMake/Make

mkdir cmakebuild
cd cmakebuild
cmake -DCMAKE_BUILD_TYPE=Release ..
make

CMake/Xcode

mkdir cmakebuild
cd cmakebuild
cmake -G Xcode ..
cmake --build . --config Release

CMake/Visual Studio

mkdir cmakebuild
cd cmakebuild
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release

CMake for Android NDK

mkdir cmakebuild
cd cmakebuild
cmake -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=$ABI -DANDROID_NATIVE_API_LEVEL=$MINSDKVERSION ..
make

See https://developer.android.com/ndk/guides/cmake for details on the choice of ABI and other parameters.

Where $NDK is set to the directory path where you have installed the NDK, $ABI is the Android ABI (ex: arm64-v8a) and $MINSDKVERSION is the minimum SDK version (ex: 23)

On Linux and other platforms, using SCons (deprecated)

Make sure you the the SCons build tool installed on your host machine (http://www.scons.org). To build the Debug configuration, simply enter the command:

scons -u

in a terminal from any directory (either from the top level directory where you downloaded the Bento4 distribution, or from the Build/Targets/xxx subdirectory for your specific target).

To build the Release configuration, use the command:

scons -u build_config=Release

To cross-compile for a target other than your host architecture, specify target=xxxx as an argument to the scons build command.

Example:

scons -u build_config=Release target=x86_64-unknown-linux

Using Make

From a command shell, go to your build target directory.

For Debug builds: make

For Release builds: make AP4_BUILD_CONFIG=Release

Installing Bento4 (vcpkg)

Alternatively, you can build and install Bento4 using vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install bento4

The Bento4 port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

Release Notes

1.6.0-638

  • support multi-bitrate audio
  • new docs using MkDocs
  • add av1 files and remove deprecated option from vs2019 build
  • add AV1 support
  • better handling of USAC signaling
  • add UTF-8 support on Windows
  • fix LGTM warnings
  • account for last sample when at EOS
  • new inspector API
  • bug fixes

1.6.0-636

Dolby Vision encryption now properly encrypts in a NAL-unit-aware mode

Previous releases

(no seaparate notes, please refer to commit logs)