Radiant Media Player

rmp-segment: node.js HLS segmenter



rmp-segment

rmp-segment is an open-source node.js HLS segmenter. It is built as a portable command line tool with ease of use in mind.

It follows the HTTP Live Streaming IETF sepcification. It uses FFmpeg for MPEG-2 TS segmenting.

rmp-segment is released under GPL version 3. Source code is available on GitHub.

Supported features include:

  • on-demand video segmenting (output to MPEG-2 TS container)
  • adaptive bitrate streaming
  • AES-128 encryption
  • multiple audio
  • audio-only (output to AAC container)

Documentation

It is assumed you have properly followed the install instructions on GitHub and are running rmp-segment in a supported environment.


Global configuration

At the root of the project lives a rmp-segment-config.json file. This is a JSON file that holds configuration options that will be applied to all segmenting tasks. By default it looks like:

{
  "debug": false,
  "tsChunkSize": 10,
  "allowCache": true
}

You can add a rmp-segment-config.json file in your current working directory and the segmenter will pick it up otherwise it will look for the default rmp-segment-config.json file.

Available values:

"ffmpeg" (String) defines the location of the FFmpeg executable which is used for MPEG-2 TS segmenting. By default the segmenter will try to locate it (utils folder within the package) based on the OS it is running on. 64-bits builds for Windows and Linux OSes are provided. If you want to use your own FFmpeg executable you can overwrite this value with the "ffmpeg" field. Example on Linux:

{
  "ffmpeg": "/home/user/myfolder/ffmpeg"
}

Or on Windows:

{
  "ffmpeg": "C:\\myfolder\\ffmpeg\\bin\\ffmpeg.exe"
}

"debug" (Boolean) when set to true it will produces logs to your debug node console (i.e. console.log). Default: false.

"tsChunkSize" (Number) defines the size of the .ts chunks in seconds. The default value is 10 as recommended by Apple. We highly recommend to keep 10 as some devices may have playback issues when this value is different from 10.

"allowCache" (Boolean) indicates whether the client MAY or MUST NOT cache downloaded media segments for later replay. Default: true.


Command line parameters

-i

Required. This parameter indicates where the rmp-segment should look for input files to segment. It should point at a folder. The segmenter will automatically read the content of the folder and start segmenting all valid files (input files must be H.264 video and/or AAC audio in .mp4, .m4a or .m4v containers).

-o

Required. This parameter indicates where the rmp-segment should put the segmented HLS files (.ts and .m3u8 files). It should point at a folder. If the folder does not exist rmp-segment will try to create it (assuming no permission issues).

The above 2 parameters are the only required to start using rmp-segment. Example:

rmp-segment -i input/bbb -o output/bbb

-aes

Optional. This will activate AES-128 encryption for segmenting. Example:

rmp-segment -i input/bbb -o output/bbb -aes

-maudio

Optional. rmp-segment will produce a compliant HLS stream with multiple-audio tracks. The files in the input folder must meet the following requirements:

  • Video files must be H.264 video-only file in a .mp4 container (the video file must not have an audio track). You can have multiple video files for adaptive bitrate streaming.
  • Audio files must be AAC audio in .mp4 or .m4a containers. Each audio files must have the following naming convention: xx-YYYY.mp4.
    • xx must be the code for the representing the names of the language for the audio-track: 2 letters ISO 639-1
    • YYYY must be a human-readable representation of the name of the language for the audio-track.
    • xx and YYYY must be separated by a - (hyphen)
    • Examples: en-English.mp4 or de-German.mp4 or it-Italian.mp4

-default_maudio 'xx'

Optional. You can set a default audio track for multiple audio segmenting. This is done through this parameter. 'xx' must be a 2 letters ISO 639-1 language code and it must correspond to one of the available input audio file.

Multiple-audio example:

rmp-segment -i input/bbb-maudio -o output/bbb-maudio -maudio -default_maudio 'en'

You can use MP4Box to extract audio-only and video-only tracks.

You can download some sample input files (test vectors upon which we test rmp-segment) here.

Failure to comply with the above requirements for multiple-audio tracks HLS segmenting is the most common source for non-working multiple-audio HLS streams.

Failure to comply with the above requirements for multiple-audio tracks HLS segmenting is the most common source for non-working multiple-audio HLS streams.