mp42hls

mp42hls is a tool that converts an MP4 file to an HLS (HTTP Live Streaming) presentation, including the generation of the segments and .m3u8 playlist as well as AES-128 and SAMPLE-AES (for FairPlay) encryption. This can be used as a replacement for Appleā€™s mediafilesegmenter tool.

Running the tool without any argument will print out a summary of the tool’s command line options and parameters.

Usage

MP4 To HLS File Converter - Version 1.1
(Bento4 Version 1.4.3.0)
(c) 2002-2015 Axiomatic Systems, LLC

usage: mp42hls [options] <input>
Options:
  --verbose
  --hls-version <n> (default: 3)
  --pmt-pid <pid>
    PID to use for the PMT (default: 0x100)
  --audio-pid <pid>
    PID to use for audio packets (default: 0x101)
  --video-pid <pid>
    PID to use for video packets (default: 0x102)
  --audio-track-id <n>
    Read audio from track ID <n> (0 means no audio)
  --video-track-id <n>
    Read video from track ID <n> (0 means no video)
  --audio-format <format>
    Format to use for audio-only segments: 'ts' or 'packed' (default: 'ts')
  --segment-duration <n>
    Target segment duration in seconds (default: 10)
  --segment-duration-threshold <t>
    Segment duration threshold in milliseconds (default: 15)
  --index-filename <filename>
    Filename to use for the playlist/index (default: stream.m3u8)
  --segment-filename-template <pattern>
    Filename pattern to use for the segments. Use a printf-style pattern with
    one number field for the segment number, unless using single file mode
    (default: segment-%d.ts for separate segment files, or stream.ts for single file)
  --segment-url-template <pattern>
    URL pattern to use for the segments. Use a printf-style pattern with
    one number field for the segment number unless unsing single file mode.
    (may be a relative or absolute URI).
    (default: segment-%d.ts for separate segment files, or stream.ts for single file)
  --iframe-index-filename <filename>
    Filename to use for the I-Frame playlist (default: iframes.m3u8 when HLS version >= 4)
  --output-single-file
    Output all the media in a single file instead of separate segment files.
    The segment filename template and segment URL template must be simple strings
    without '%d' or other printf-style patterns
  --encryption-mode <mode>
    Encryption mode (only used when --encryption-key is specified). AES-128 or SAMPLE-AES (default: AES-128)
  --encryption-key <key>
    Encryption key in hexadecimal (default: no encryption)
  --encryption-iv-mode <mode>
    Encryption IV mode: 'sequence', 'random' or 'fps' (FairPlay Streaming) (default: sequence)
    (when the mode is 'fps', the encryption key must be 32 bytes: 16 bytes for the key
    followed by 16 bytes for the IV).
  --encryption-key-uri <uri>
    Encryption key URI (may be a realtive or absolute URI). (default: key.bin)
  --encryption-key-format <format>
    Encryption key format. (default: 'identity')
  --encryption-key-format-versions <versions>
    Encryption key format versions.

Examples