### Install Targets and Headers Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Installs the built library, executables, and header files to their designated locations. ```cmake install( TARGETS ap4 ${BENTO4_APPS_LOWERCASE} EXPORT "${TARGETS_EXPORT_NAME}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) install( FILES ${AP4_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bento4" ) ``` -------------------------------- ### Build Example Applications Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Enables building example applications if BUILD_APPS is ON. It finds all applications in the Apps directory, compiles them, and links them against the AP4 library. ```cmake option(BUILD_APPS "Build example applications" ON) if(BUILD_APPS) file(GLOB BENTO4_APPS RELATIVE ${SOURCE_ROOT}/Apps ${SOURCE_ROOT}/Apps/*) foreach(app ${BENTO4_APPS}) string(TOLOWER ${app} binary_name) list(APPEND BENTO4_APPS_LOWERCASE ${binary_name}) add_executable(${binary_name} ${SOURCE_ROOT}/Apps/${app}/${app}.cpp) target_link_libraries(${binary_name} ap4) if(MSVC) set_property(TARGET ${binary_name} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") target_compile_definitions(${binary_name} PRIVATE -D_CONSOLE) endif() endforeach() endif(BUILD_APPS) ``` -------------------------------- ### Configure Package Installation Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Sets up variables for package configuration file generation and installation paths. ```cmake include(GNUInstallDirs) set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") set(namespace "${PROJECT_NAME}::") include(CMakePackageConfigHelpers) write_basic_package_version_file( "${version_config}" COMPATIBILITY SameMajorVersion ) configure_package_config_file( "Build/cmake/Config.cmake.in" "${project_config}" INSTALL_DESTINATION "${config_install_dir}" ) configure_file( "Build/pkgconfig/bento4.pc.in" "${generated_dir}/bento4.pc" @ONLY ) ``` -------------------------------- ### Install Bento4 using vcpkg Source: https://github.com/axiomatic-systems/bento4/blob/master/README.md Build and install Bento4 using the vcpkg dependency manager. This involves cloning vcpkg, integrating it, and then installing the bento4 package. ```bash git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install ./vcpkg install bento4 ``` -------------------------------- ### Install Package Configuration Files Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Installs the generated CMake package configuration files and pkgconfig file. ```cmake install( FILES "${project_config}" "${version_config}" DESTINATION "${config_install_dir}" ) install( FILES "${generated_dir}/bento4.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" ) ``` -------------------------------- ### Combine Multiple DRMs with mp4dash Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/encryption_and_drm.md This example demonstrates packaging a video file compatible with Marlin, PlayReady, and Widevine DRMs simultaneously by combining their respective command-line options. ```bash mp4dash --encryption-key=09e367028f33436ca5dd60ffe6671e70:b42ca3172ee4e69bf51848a59db9cd13 --marlin --playready-header=LA_URL:http://playready.directtaps.net/pr/svc/rightsmanager.asmx --widevine-header=provider:widevine_test#content_id:2a video-source.mp4 ``` -------------------------------- ### Basic mp4dash Usage Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/documentation/mp4dash.md This is a basic example of how to use mp4dash to create a DASH-compliant MP4 file. Ensure the input file is a valid MP4. The output file will be named 'output.mp4'. ```bash mp4dash input.mp4 --output-mp4 output.mp4 ``` -------------------------------- ### Run AFL Fuzzer with mp4info Source: https://github.com/axiomatic-systems/bento4/blob/master/Build/Targets/x86-afl-linux/README.txt This command executes the AFL fuzzer against the instrumented mp4info binary. Ensure AFL is installed and the input/output directories are set up. ```bash $ afl-fuzz -i input -o output \ ~/Development/Bento4/Build/Targets/x86-afl-linux/Debug/mp4info \ ~/Development/Test/Bento4Afl/input/init.mp4 ``` -------------------------------- ### Limit HLS stream combinations with specific audio group matches Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/multi_bitrate_audio.md Uses `hls_group` for audio and `hls_group_match` to restrict combinations. This example combines specific audio bitrates ('audio_16', 'audio_32', 'audio_64') with the first video, and 'audio128' with the other two videos. ```bash mp4dash --hls [+hls_group=audio_16]audio-16kbps.mp4 [+hls_group=audio_32]audio-32kbps.mp4 [+hls_group=audio_64]audio-64kbps.mp4 [+hls_group=audio_128]audio-128kbps.mp4 "[+hls_group_match=audio_16&audio_32&audio_64&audio_64]video_00500.mp4" "[+hls_group_match=audio128]video_00800.mp4" "[+hls_group_match=audio128]video_01400.mp4" ``` -------------------------------- ### Invoking mp4-dash.py script Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/index.md Use this command to invoke the mp4-dash.py script directly from a source distribution. Ensure Python 3.7+ is installed. ```bash python3 /mp4-dash.py ``` -------------------------------- ### Control HLS stream combinations with hls_group and hls_group_match Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/multi_bitrate_audio.md Uses `hls_group` to assign audio groups and `hls_group_match` to specify which audio groups combine with video. This example combines all audio with the first video, and only 'audio128' with the other two videos. ```bash mp4dash --hls [+hls_group=audio_16]audio-16kbps.mp4 [+hls_group=audio_32]audio-32kbps.mp4 [+hls_group=audio_64]audio-64kbps.mp4 [+hls_group=audio_128]audio-128kbps.mp4 "[+hls_group_match=*]video_00500.mp4" "[+hls_group_match=audio128]video_00800.mp4" "[+hls_group_match=audio128]video_01400.mp4" ``` -------------------------------- ### Define Include Directories Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Specifies public include directories for the AP4 library, making headers available during build and installation. ```cmake set(AP4_INCLUDE_DIRS $ $ $ $ ) ``` -------------------------------- ### Package Video with Widevine DRM using mp4dash Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/encryption_and_drm.md Use the --widevine-header option to specify Widevine DRM data, either as a hex-encoded PSSH payload or as name:value pairs. This example shows packaging a video file with Widevine encryption. ```bash mp4dash --widevine-header provider:widevine_test#content_id:2a --encryption-key 90351951686b5e1ba222439ecec1f12a:0a237b0752cbf1a827e2fecfb87479a2 video-source.mp4 ``` ```bash mp4dash --widevine-header "#CAESEJA1GVFoa14boiJDns7B8SoaDXdpZGV2aW5lX3Rlc3QiASo=" --encryption-key 90351951686b5e1ba222439ecec1f12a:0a237b0752cbf1a827e2fecfb87479a2 video-source.mp4 ``` -------------------------------- ### Get Bento4 Version Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Defines a function to extract the Bento4 version string from a header file. This function reads a specific header and uses regular expressions to find and set the version. ```cmake function(get_bento4_version) file(STRINGS "Source/C++/Core/Ap4Version.h" _temp REGEX "AP4_VERSION_STRING") string(REGEX MATCH "\"([^\"]+)\"" _temp "${_temp}") set(BENTO4_VERSION "${CMAKE_MATCH_1}" PARENT_SCOPE) endfunction() get_bento4_version() ``` -------------------------------- ### Initialize and Configure Receiver Application Source: https://github.com/axiomatic-systems/bento4/blob/master/Test/Chromecast/receiver/index.html Sets up the receiver application, enables debug logging if specified in the URL, and initializes the media manager. This code should be run when the window loads. ```javascript window.onload = function() { // If you set ?Debug=true in the URL, such as a different App ID in the // developer console, include debugging information. if (window.location.href.indexOf('Debug=true') != -1) { console.log('---------- DEBUG ON ------------'); cast.receiver.logger.setLevelValue(cast.receiver.LoggerLevel.DEBUG); cast.player.api.setLoggerLevel(cast.player.api.LoggerLevel.DEBUG); } var mediaElement = document.getElementById('vid'); window.mediaManager = new cast.receiver.MediaManager(mediaElement); window.defaultOnLoad = mediaManager.onLoad.bind(mediaManager); mediaManager.onLoad = function (event) { console.log('Event:', event); // The Media Player Library requires that you call player unload between different invocations. if (window.player !== null) { console.log('unloading the player'); player.unload(); // Must unload before starting again. window.player = null; } if (event.data\[\'media\'\] && event.data\[\'media\'\]\[\'contentId\'\]) { console.log('Starting media application'); console.log(event.data\[\'media\'\]); var url = event.data\[\'media\'\]\[\'contentId\'\]; window.host = new cast.player.api.Host( {'mediaElement':mediaElement, 'url':url}); var initStart = event.data\[\'media\'\]\[\'currentTime\'\] || 0; var autoplay = event.data\[\'autoplay\'\] || true; var protocol = null; mediaElement.autoplay = autoplay; // Make sure autoplay gets set if (url.lastIndexOf('.m3u8') >= 0) { // HTTP Live Streaming console.log("=== HLS ==="); protocol = cast.player.api.CreateHlsStreamingProtocol(host); } else if (url.lastIndexOf('/mpd') >= 0 || url.lastIndexOf('.mpd') >= 0) { // MPEG-DASH console.log("=== DASH ==="); protocol = cast.player.api.CreateDashStreamingProtocol(host); } else if (url.indexOf('/Manifest') >= 0) { // Smooth Streaming console.log("=== SMOOTH ==="); protocol = cast.player.api.CreateSmoothStreamingProtocol(host); } host.onError = function(errorCode) { console.log("Fatal Error - "+errorCode); if (window.player) { console.log("unloading player"); window.player.unload(); window.player = null; } }; host.updateLicenseRequestInfo = function(requestInfo) { console.log("Setting License Request Info headers"); requestInfo.headers = { "Content-Type": "application/octet-stream" }; } if (event.data.customData && event.data.customData.licenseCustomData) { console.log('setting license custom data'); host.licenseCustomData = event.data.customData.licenseCustomData; } if (event.data.customData && event.data.customData.licenseUrl) { console.log('setting license URL'); host.licenseUrl = event.data.customData.licenseUrl; } if (protocol !== null) { console.log("Starting Media Player Library"); window.player = new cast.player.api.Player(host); window.player.load(protocol, initStart); } else { console.log("using default handler"); window.defaultOnLoad(event); // do the default process } } } window.player = null; console.log('014 Application is ready, starting system'); window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance(); castReceiverManager.start(); }; ``` -------------------------------- ### Create HLS playlist with all audio/video combinations Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/multi_bitrate_audio.md Generates an HLS playlist for 4 audio bitrates and 3 video bitrates, listing all possible N*M combinations. Expects 12 `#EXT-X-STREAM-INF` entries. ```bash mp4dash --hls audio-16kbps.mp4 audio-32kbps.mp4 audio-64kbps.mp4 audio-128kbps.mp4 video_00500.mp4 video_00800.mp4 video_01400.mp4 ``` -------------------------------- ### Build with CMake and Make Source: https://github.com/axiomatic-systems/bento4/blob/master/README.md Use CMake to generate Makefiles for building the project. This is a common approach for Linux and other platforms. ```bash mkdir cmakebuild cd cmakebuild cmake -DCMAKE_BUILD_TYPE=Release .. make ``` -------------------------------- ### Select French Audio from one file and Video from another Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/index.md Combine `type` and `language` selectors to pick specific audio tracks from one input file, and use a `type` selector to pick the video track from a different input file. ```bash mp4dash [type=audio,language=fr]video1.mp4 [type=video]video2.mp4 ``` -------------------------------- ### Sign Attributes with Python Source: https://github.com/axiomatic-systems/bento4/blob/master/Test/Tools/MakeSignedAttributes.txt Use the MakeSignedAttributes.py script to sign attributes for DRM. Requires private key, certificate, and attribute definitions. ```bash python MakeSignedAttributes.py attr.priv attr.cert 1:2:http://blabla.com/foo.xml 2:2:http://blabla.com/bar.xml ``` -------------------------------- ### Build with Make (Release) Source: https://github.com/axiomatic-systems/bento4/blob/master/README.md Build the Release version of Bento4 using Make. Set the AP4_BUILD_CONFIG environment variable to 'Release'. ```bash make AP4_BUILD_CONFIG=Release ``` -------------------------------- ### mp42ts Usage and Options Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/documentation/mp42ts.md This displays the command-line usage and available options for the mp42ts converter. Use these options to control PID assignments, segmentation, and other conversion parameters. ```bash MP4 To MPEG2-TS File Converter - Version 1.3 (Bento4 Version 1.6.0.0) (c) 2002-2018 Axiomatic Systems, LLC usage: mp42ts [options] Options: --pmt-pid (default: 0x100) --audio-pid (default: 0x101) --video-pid (default: 0x102) --segment [with this option, the name must be a 'printf' template, like "seg-%d.ts"] --segment-duration-threshold in ms (default = 50) [only used with the --segment option] --pcr-offset in units of 90kHz (default 10000) --verbose --playlist --playlist-hls-version (default=3) ``` -------------------------------- ### Create HLS playlist with 4 audio and 1 video bitrate Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/multi_bitrate_audio.md Generates an HLS playlist combining 4 audio bitrates with a single video bitrate. The playlist will contain 4 `#EXT-X-STREAM-INF` entries. ```bash mp4dash --hls audio-16kbps.mp4 audio-32kbps.mp4 audio-64kbps.mp4 audio-128kbps.mp4 video_00500.mp4 ``` -------------------------------- ### Build with Make (Debug) Source: https://github.com/axiomatic-systems/bento4/blob/master/README.md Build the Debug version of Bento4 using Make. Navigate to your build target directory before running this command. ```bash make ``` -------------------------------- ### Build with SCons (Release) Source: https://github.com/axiomatic-systems/bento4/blob/master/README.md Build the Release configuration of Bento4 using SCons. Specify 'build_config=Release' to enable optimizations. ```bash scons -u build_config=Release ``` -------------------------------- ### mp4tag Usage and Commands Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/documentation/mp4tag.md Displays the general usage and available commands for the mp4tag tool. Use this to understand the basic syntax and options for file tagging. ```bash MP4 File Tagger - Version 1.2 (Bento4 Version 1.6.0.0) (c) 2002-2008 Axiomatic Systems, LLC usage: mp4tag [options] [commands...] [] commands: --help print this usage information --show-tags show tags found in the input file --list-symbols list all the builtin symbols --list-keys list all the builtin symbolic key names --set :: set a tag (if the tag does not already exist, set behaves like add) --add :: set/add a tag where is: S if is a UTF-8 string LS if is a UTF-8 string with a language code (see notes) I8 if is an 8-bit integer I16 if is a 16-bit integer I32 if is a 32-bit integer JPEG if is the name of a JPEG file GIF if is the name of a GIF file B if is a binary string (see notes) Z if is the name of a builtin symbol --remove remove a tag --extract : extract the value of a tag and save it to a file NOTES: In all commands with a argument, except for '--add', can be or #n where n is the zero-based index of the key when there is more than one key with the same name (ex: multiple images for cover art). A has the form / or simply (in which case the namespace defaults to 'meta'). The of a key is either one of a symbolic keys (see --list-keys) or a 4-character atom name. The namespace can be 'meta' for itunes-style metadata or 'dcf' for OMA-DCF-style metadata, or a user-defined long-form namespace (ex: com.mycompany.foo). Binary strings can be expressed as a normal string of ASCII characters prefixed by a + character if all the bytes fall in the ASCII range, or hex-encoded prefixed by a # character (ex: +hello, or #0FC4) Strings with a language code are expressed as: :, where is a 3 character language code (ex: eng:hello) ``` -------------------------------- ### mp4dash Command-Line Usage Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/documentation/mp4dash.md This shows the basic usage and available options for the mp4dash command-line tool. It details how to specify input media files and various configuration parameters for outputting DASH and HLS manifests. ```bash Usage: mp4-dash.py [options] [ ...] Each is the path to a fragmented MP4 file, optionally prefixed with a stream selector delimited by [ and ]. The same input MP4 file may be repeated, provided that the stream selector prefixes select different streams. Version 2.0.0 r637 Options: -h, --help show this help message and exit -v, --verbose Be verbose -d, --debug Print out debugging information -o , --output-dir= Output directory -f, --force Allow output to an existing directory --mpd-name= MPD file name --profiles= Comma-separated list of one or more profile(s). Complete profile names can be used, or profile aliases ('live'='urn:mpeg:dash:profile:isoff-live:2011', 'on- demand'='urn:mpeg:dash:profile:isoff-on-demand:2011', 'hbbtv-1.5='urn:hbbtv:dash:profile:isoff-live:2012') --no-media Do not output media files (MPD/Manifests only) --rename-media Use a file name pattern instead of the base name of input files for output media files. --media-prefix= Use this prefix for prefixed media file names (instead of the default prefix "media") --init-segment= Initialization segment name --no-split Do not split the file into individual segment files --use-segment-list Use segment lists instead of segment templates --use-segment-template-number-padding Use padded numbers in segment URL/filename templates --use-segment-timeline Use segment timelines (necessary if segment durations vary) --min-buffer-time= Minimum buffer time (in seconds) --max-playout-rate= Max Playout Rate setting strategy for trick-play support. Supported strategies: lowest:X --language-map=:[,...] Remap language code to . Multiple mappings can be specified, separated by ',' --always-output-lang Always output an @lang attribute for audio tracks even when the language is undefined --subtitles Enable Subtitles --attributes= Specify the attributes of a set of tracks. This option may be used multiple times, once per attribute set. --smooth Produce an output compatible with Smooth Streaming --smooth-client-manifest-name= Smooth Streaming Client Manifest file name --smooth-server-manifest-name= Smooth Streaming Server Manifest file name --smooth-h264-fourcc= Smooth Streaming FourCC value for H.264 video (default=H264) [some older players use AVC1] --hls Output HLS playlists in addition to MPEG DASH --hls-key-url= HLS key URL (default: key.bin) --hls-master-playlist-name= HLS master playlist name (default: master.m3u8) --hls-media-playlist-name= HLS media playlist name (default: media.m3u8) --hls-iframes-playlist-name= HLS I-Frames playlist name (default: iframes.m3u8) --hippo Produce an output compatible with the Hippo Media Server --hippo-server-manifest-name= Hippo Media Server Manifest file name --use-compat-namespace Use the original DASH MPD namespace as it was specified in the first published specification --use-legacy-audio-channel-config-uri Use the legacy DASH namespace URI for the AudioChannelConfiguration descriptor --encryption-key= Encrypt some or all tracks with MPEG CENC (AES-128), where specifies the KID(s) and Key(s) to use, using one of the following forms: (1) : or :: with (and if specififed) as a 32-character hex string and either a 32-character hex string or the character '#' followed by a base64-encoded key seed; or (2) @ where is an expression of one of the supported key locator schemes. Each entry may ``` -------------------------------- ### Include Two WebVTT Subtitles Files Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/subtitles.md Use this command to include multiple WebVTT subtitles files, each with its own language specification, in the DASH presentation. ```bash mp4dash video_00500.mp4 [+format=webvtt,+language=eng]sub_eng_webvtt.txt [+format=webvtt,+language=fre]sub_fre_webvtt.txt ``` -------------------------------- ### Generate Multi-Bitrate DASH Presentation with mp4dash Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/index.md Package multiple video streams, each encoded at a different bitrate, into a single DASH presentation. Ensure input files have closed GOPs, equal durations, and compatible audio parameters for adaptive streaming. ```bash mp4dash video_1000.mp4 video_2000.mp4 video_3000.mp4 ``` -------------------------------- ### Build with CMake and Visual Studio Source: https://github.com/axiomatic-systems/bento4/blob/master/README.md Configure CMake to generate Visual Studio project files for building on Windows. The --build option is used for compilation. ```bash mkdir cmakebuild cd cmakebuild cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build . --config Release ``` -------------------------------- ### Create HLS playlist with audio-only streams Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/multi_bitrate_audio.md Generates an HLS playlist with only audio streams, specifying different bitrates. No video streams are included. ```bash mp4dash --hls audio-16kbps.mp4 audio-32kbps.mp4 audio-64kbps.mp4 audio-128kbps.mp4 ``` -------------------------------- ### MP4 DCF Packager Usage Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/documentation/mp4dcfpackager.md This snippet outlines the basic usage and available options for the mp4dcfpackager command-line tool. ```APIDOC ## MP4 DCF Packager ### Description MP4 DCF Packager is a tool for packaging MP4 files according to DCF specifications, supporting various encryption methods. ### Method Command-line tool ### Endpoint N/A (Local executable) ### Parameters #### Command-line Arguments - **--method** (string) - Required - Specifies the encryption method: NULL, CBC, or CTR. - **--show-progress** (flag) - Optional - Displays progress details during packaging. - **--content-type** (string) - Optional - Sets the content MIME type. - **--content-id** (string) - Optional - Sets the content ID. - **--rights-issuer** (URL) - Optional - Specifies the URL of the rights issuer. - **--key** (string) - Optional - Specifies the encryption key and IV in the format ":". - **** (hex string) - A 128-bit key (32 hex characters). - **** (hex string) - A 128-bit IV or salting key (32 hex characters). - **--textual-header** (string) - Optional - Specifies a textual header in the format ":". This option can be used multiple times. - **** (file path) - Required - The input MP4 file. - **** (file path) - Required - The output packaged MP4 file. ### Request Example ```bash mp4dcfpackager --method CBC --key 0123456789abcdef0123456789abcdef:fedcba9876543210fedcba9876543210 --content-type "video/mp4" input.mp4 output.mp4 ``` ### Response N/A (Command-line tool produces output files and status messages) ``` -------------------------------- ### mp42hevc Usage and Options Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/documentation/mp42hevc.md This snippet shows the basic usage and available options for the mp42hevc command-line tool. Use the --key option to provide a decryption key for encrypted files. ```bash MP4 To HEVC File Converter - Version 1.0 (Bento4 Version 1.6.0.0) (c) 2002-2014 Axiomatic Systems, LLC usage: mp42hevc [options] Options: --key : 128-bit decryption key (in hex: 32 chars) ``` -------------------------------- ### Include Single English WebVTT Subtitles Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/subtitles.md Use this command to include a single English WebVTT subtitles file in the DASH presentation. Specify the format and language using input specifiers. ```bash mp4dash video.mp4 [+format=webvtt,+language=eng]sub_eng_webvtt.txt ``` -------------------------------- ### Build with SCons (Debug) Source: https://github.com/axiomatic-systems/bento4/blob/master/README.md Build the Debug configuration of Bento4 using SCons. This command can be run from any directory within the distribution. ```bash scons -u ``` -------------------------------- ### mp42aac Usage and Options Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/documentation/mp42aac.md This displays the basic usage and available options for the mp42aac command-line tool. Use it to convert MP4 files to AAC format, with an option to specify a decryption key. ```bash MP4 To AAC File Converter - Version 1.0 (Bento4 Version 1.6.0.0) (c) 2002-2008 Axiomatic Systems, LLC usage: mp42aac [options] Options: --key : 128-bit decryption key (in hex: 32 chars) ``` -------------------------------- ### Ensuring PIFF Compatibility for PlayReady Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/encryption_and_drm.md To ensure compatibility with PlayReady clients that do not support 16-byte IVs, use the `--encryption-args` option with `mp4dash` to enable PIFF compatibility. This is equivalent to using `--global-option mpeg-cenc.piff-compatible:true` with `mp4encrypt`. ```bash mp4dash --encryption-args="--global-option mpeg-cenc.piff-compatible:true" ``` -------------------------------- ### mp42avc Usage and Options Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/documentation/mp42avc.md This snippet shows the basic usage and available options for the mp42avc command-line tool. Use the --key option to provide a decryption key for encrypted files. ```bash MP4 To AVC File Converter - Version 1.0 (Bento4 Version 1.6.0.0) (c) 2002-2009 Axiomatic Systems, LLC usage: mp42avc [options] Options: --key : 128-bit decryption key (in hex: 32 chars) ``` -------------------------------- ### Build with CMake and Xcode Source: https://github.com/axiomatic-systems/bento4/blob/master/README.md Generate Xcode project files using CMake for building on macOS. The --build option can be used for building directly. ```bash mkdir cmakebuild cd cmakebuild cmake -G Xcode .. cmake --build . --config Release ``` -------------------------------- ### Encrypting DASH with PlayReady DRM Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/encryption_and_drm.md Package a video file for PlayReady DRM using `mp4dash`. Specify the encryption key and the License Acquisition URL (LA_URL) for the PlayReady header. This command automatically uses 8-byte IVs for compatibility with some PlayReady clients. ```bash mp4dash --encryption-key=09e367028f33436ca5dd60ffe6671e70:b42ca3172ee4e69bf51848a59db9cd13 --playready-header=LA_URL:http://playready.directtaps.net/pr/svc/rightsmanager.asmx video-source.mp4 ``` -------------------------------- ### mp4edit Usage Information Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/documentation/mp4edit.md Displays the command-line usage for the mp4edit tool, outlining available commands and their syntax for editing MP4 files. ```bash MP4 File Editor - Version 1.2 (Bento4 Version 1.6.0.0) (c) 2002-2017 Axiomatic Systems, LLC usage: mp4edit [commands] where commands include one or more of: --insert :[:] --remove --replace : and may be either a filename for a file that contains the atom data (header and payload), or # with specifying an atom uuid type, as a 32-character hex value, and a file with the atom payload only. ``` -------------------------------- ### Create CMAF Presentation with HLS Support using mp4dash Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/cmaf/index.md Use the mp4dash tool with the --hls option to create a CMAF presentation that supports both HLS and MPEG DASH. This allows a single set of media segments to be used for both streaming protocols. ```bash mp4dash --hls your-media-files... ``` -------------------------------- ### Set Project Version Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Sets the project name and version using the extracted Bento4 version. ```cmake project(bento4 VERSION "${BENTO4_VERSION}") ``` -------------------------------- ### Generate Single Bitrate DASH Presentation with mp4dash Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/index.md Create a DASH presentation from a single fragmented MP4 file using the mp4dash tool. This generates the MPD file and media segments in the default 'output' directory. ```bash mp4dash video.mp4 ``` -------------------------------- ### Package Multi-Bitrate Audio and Video Files Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/multi_bitrate_audio.md Use the mp4dash tool to package multiple audio files with different bitrates along with video files for adaptive streaming. No special options are required for xHE-AAC audio. ```bash mp4dash audio-16kbps.mp4 audio_32kbps.mp4 audio-64kbps.mp4 audio-128kbps.mp4 video-500kbps.mp4 video-2000kbps.mp4 ``` -------------------------------- ### Select French Audio and Video Track Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/index.md Use the `language` selector to specify the desired audio track and the `type` selector to include the video track. This command selects the French audio track and the video track from video.mp4. ```bash mp4dash [language=fr]video.mp4 ``` -------------------------------- ### Clone Bento4 Source Code Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/index.md Use this command to download the latest source code from the Bento4 GitHub repository. ```bash git clone https://github.com/axiomatic-systems/Bento4.git ``` -------------------------------- ### Set macOS Deployment Target Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Specifies the minimum macOS version for which the application will be compatible. ```cmake if(APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12) endif() ``` -------------------------------- ### Set MSVC Runtime Library Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Configures the C runtime library for the AP4 target on MSVC to use the statically linked version and defines _LIB. ```cmake if(MSVC) set_property(TARGET ap4 PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") target_compile_definitions(ap4 PRIVATE -D_LIB) endif() ``` -------------------------------- ### Select Track ID 3 and all tracks Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/index.md Use the `track` selector to specify a particular track ID from one input file, while including all tracks from another input file. ```bash mp4dash [track=3]video1.mp4 video2.mp4 ``` -------------------------------- ### Include Single TTML Subtitles Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/subtitles.md Use this command to include a single TTML subtitles file in the DASH presentation. Specify the format using the input specifier. ```bash mp4dash video.mp4 [+format=ttml]sub_fre_ttml.xml ``` -------------------------------- ### Fragmenting MP4 files with mp4fragment Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/index.md Use the mp4fragment tool to convert non-fragmented MP4 files into fragmented MP4 files, which are required for MPEG DASH. ```bash mp4fragment video.mp4 video-fragmented.mp4 ``` -------------------------------- ### Encrypting DASH with Marlin DRM Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/encryption_and_drm.md Use the `--marlin` option with `mp4dash` to automatically include Marlin DRM signaling in the MPD. Requires a KID and encryption key. ```bash mp4dash --marlin --encryption-key=121a0fca0f1b475b8910297fa8e0a07e:a0a1a2a3a4a5a6a7a8a9aaabacadaeaf source_400kbps.mp4 source_800kbps.mp4 ``` -------------------------------- ### Include Separate MP4 Subtitles File Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/subtitles.md Use the --subtitles option when providing separate MP4 files for video/audio and subtitles. mp4dash will package the subtitles from the specified file. ```bash mp4dash --subtitles video.mp4 subtitles.mp4 ``` -------------------------------- ### Build for Android NDK with CMake Source: https://github.com/axiomatic-systems/bento4/blob/master/README.md Cross-compile Bento4 for Android using CMake and the Android NDK. Ensure NDK path, ABI, and minimum SDK version are correctly set. ```bash mkdir cmakebuild cd cmakebuild cmake -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=$ABI -DANDROID_NATIVE_API_LEVEL=$MINSDKVERSION .. make ``` -------------------------------- ### Encrypt Media with mp4encrypt for DASH CENC Source: https://github.com/axiomatic-systems/bento4/blob/master/Documents/MkDocs/src/developers/dash/encryption_and_drm.md Use the mp4encrypt command-line tool to encrypt an MP4 video file in MPEG DASH CENC mode before packaging with mp4dash. This provides more control over the encryption process. ```bash mp4encrypt --method MPEG-CENC --key 1:a0a1a2a3a4a5a6a7a8a9aaabacadaeaf:0123456789abcdef --property 1:KID:121a0fca0f1b475b8910297fa8e0a07e --key 2:a0a1a2a3a4a5a6a7a8a9aaabacadaeaf:aaaaaaaabbbbbbbb --property 2:KID:121a0fca0f1b475b8910297fa8e0a07e hbb_578kbps.mp4 hbb_578kbps-cenc.mp4 ``` -------------------------------- ### Define Source Directories Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Defines variables for common source code directories to simplify file globbing and target definitions. ```cmake set(SOURCE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/Source/C++) set(SOURCE_CODECS ${SOURCE_ROOT}/Codecs) set(SOURCE_CORE ${SOURCE_ROOT}/Core) set(SOURCE_CRYPTO ${SOURCE_ROOT}/Crypto) set(SOURCE_METADATA ${SOURCE_ROOT}/MetaData) set(SOURCE_SYSTEM ${SOURCE_ROOT}/System) ``` -------------------------------- ### Glob Source Files Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Finds all .cpp files in the specified source directories for the AP4 library. ```cmake file(GLOB AP4_SOURCES ${SOURCE_CODECS}/*.cpp ${SOURCE_CORE}/*.cpp ${SOURCE_CRYPTO}/*.cpp ${SOURCE_METADATA}/*.cpp ${SOURCE_SYSTEM}/StdC/*.cpp ) ``` -------------------------------- ### Set macOS Architecture Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Configures the target architectures for macOS builds to support both ARM64 and x86_64. ```cmake if(APPLE) set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "") endif() ``` -------------------------------- ### Build AP4 Library Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Configures the build of the AP4 library, either as a shared or static library based on the BUILD_SHARED_LIBRARY option. ```cmake option(BUILD_SHARED_LIBRARY "Build as a shared library" OFF) if(BUILD_SHARED_LIBRARY) add_library(ap4 SHARED ${AP4_SOURCES}) else() add_library(ap4 STATIC ${AP4_SOURCES}) endif() target_include_directories(ap4 PUBLIC ${AP4_INCLUDE_DIRS} ) ``` -------------------------------- ### Set Build Type Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Configures the build type for CMake. Use 'Debug' for development and 'Release' for production builds. ```cmake cmake -DCMAKE_BUILD_TYPE=Debug .. cmake -DCMAKE_BUILD_TYPE=Release .. ``` -------------------------------- ### Glob Header Files Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Finds all header files (.h) in the specified source directories for the AP4 library. ```cmake file(GLOB AP4_HEADERS ${SOURCE_CORE}/*.h ${SOURCE_CODECS}/*.h ${SOURCE_CRYPTO}/*.h ${SOURCE_METADATA}/*.h ) ``` -------------------------------- ### Set Minimum CMake Version Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Sets the minimum required CMake version. This ensures compatibility with specific CMake features. ```cmake if(MSVC) cmake_policy(SET CMP0091 NEW) cmake_minimum_required(VERSION 3.15) else() cmake_minimum_required(VERSION 3.10) endif() ``` -------------------------------- ### Add Platform-Specific Sources Source: https://github.com/axiomatic-systems/bento4/blob/master/CMakeLists.txt Includes platform-specific source files based on the operating system. Adds Windows-specific random number generator for Win32, or POSIX for others. ```cmake if(WIN32) set(AP4_SOURCES ${AP4_SOURCES} ${SOURCE_SYSTEM}/Win32/Ap4Win32Random.cpp) else() set(AP4_SOURCES ${AP4_SOURCES} ${SOURCE_SYSTEM}/Posix/Ap4PosixRandom.cpp) endif() ```