CLI Packager Guide

Overview

This document describes the basic concepts and how to use the command line interface (CLI) based content packaging tool used for the PallyCon multi-DRM cloud service.

There are four types of content packaging:

  1. NCG: Content encryption by Inka Entworks’ proprietary NCG (Netsync Content Guard) DRM for downloading or progressive download scenario.
  2. DASH: A method of applying PlayReady and Widevine Modular DRM by packaging streaming contents with MPEG-DASH CENC standard.
  3. HLS: A method of applying FPS (FairPlay Streaming) DRM by packaging HLS-AES streaming contents.
  4. HLS-NCG: HLS-AES content packaging with clear key protected by NCG DRM.

In addition, there are two types of CID(Content ID) input method. One is a direct input using an execution parameter of CLI Packager, and the other is using a packaging callback page method.

flow1

Integration architecture and supported environments

flow2

PallyCon CLI Packager works in conjunction with PallyCon Multi DRM Cloud Server. PallyCon cloud server manages the content key information for each service site, and when a client requests DRM license information, it finds the key (CEK) information associated with the CID and issues a license.

  • Supported OS: Support 64 bit Windows, Linux (Ubuntu, CentOS)
  • For Linux environment, gcc and g ++ library version 6.0 or later must be installed.
  • Available disk space should be at least twice the size of the contents for packaging.
  • Only alphanumeric characters are allowed for input / output filenames.

PallyCon CLI Packager is based on Google’s Shaka Packager. Please refer to Github page for details, documentation and source code of Shaka Packager.

Packager execution parameters

You can use additional Shaka Packager commands in the command format below.

Command format

./PallyConPackager --site_id value --access_key value --content_id value -i value -o value (--dash || --hls || --ncg || --hls_ncg)

Common options

Name Type Required Description
--dash bool Y Perform DASH-CENC(Widevine, PlayReady) packaging
--hls bool Y Perform HLS-AES (FPS) packaging
--ncg bool Y Perform NCG packaging
--hls_ncg bool Y Perform HLS-AES (NCG) packaging. Generate HLS-AES content to protect keys using NCG DRM.
-i (--input_file) string Y Source filename. Enable adaptive streaming if two or more files are input.
-o (--output_dir) string N Output folder name.
Default: Create an output directory at the current location (add the -f command to allow folders and files to be overwritten)
--config_file string N Config filename with fixed options such as Site ID and access key. Json and XML standards are supported. The default is Json (xml parsing is applied if the file extension is xml)
--clear_lead string N Encryption disabled section. Default: 0 (second)
--fragment_duration string N Fragment duration (seconds)
--segment_duration string N Segment duration (seconds)
--on_demand bool N Apply on-demand profile in DASH packaging.
If omitted or ‘N’, live profile is used.
--output_single_file bool N Set HLS packaging output as fMP4 file
--mpd_filename string N Filename of DASH manifest (.mpd)
--m3u8_filename string N Filename of HLS master manifest (.m3u8)
--subtitle string N Filename of subtitles
--content_id string N Set CID manually instead of using callback. (Maximum 200 bytes)
Required when using external key.
--site_id string Y Service site ID (4 bytes) issued by PallyCon
--access_key string Y Authentication key issued to the service site.
Can be checked on PallyCon Console site.

Options for using external keys

This option is used when packaging with a key that is managed separately by the service site, without using the encryption key generated by PallyCon key server.

--site_id and --access_key options are not used when using external keys.

Name Type Required Description
--enable_raw_key_encryption bool Y Enable the use of external key
--content_id string Y Set CID manually. Maximum 200 bytes
--provider string N DRM Provider name for Widevine PSSH
Default: inkaentworks
--license_url string N License acquisition URL
Default: https://license.pallycon.com/ri/licenseManager.do
--keys string Y Encryption key and key ID pair (HEX)
--ncg_cek string Y (NCG DRM packaging) 32 bytes key for NCG DRM (HEX)
--iv string N 16 bytes initial vector (HEX)
--pssh string Y PlayReady, Widevine PSSH data

Error code

Result format

<?xml version="1.0" encoding="UTF-8"?> 
<PallyconPackager>
    <RESULT>0</RESULT>
</PallyconPackager>

RESULT: ‘0’ if succeeded. Error code if failed.

Error codes

Error Code Description
0 Succeeded
1101 None of the argument values ​​after the run command are passed.
1102 An invalid parameter value was entered. (Please refer to INFO.)
1103 The number of the following argument values ​​is not correct.
1201 The file is not located in the specified path.
1202 Can not access file. (Permission / file name problem)
1203 Creation failed because the path to the file / folder is too long.
1204 Creation failed because file / folder name is too long.
1205 File / folder creation failed due to insufficient storage space.
1206 Moving to that location in the file failed.
1207 Failed to get file size.
2001 An error occurred while sending the request to the server.
2002 An error was returned from the server. (Please refer to INFO.)
2003 Invalid block size.
2004 You do not have a private key.
2005 Invalid private key.

Example

Site ID and Access Key among the input values can be checked on the console site after joining PallyCon service.

HLS-NCG packaging

HLS-AES128 stream packaging that protects clear keys with NCG DRM.

./PallyConPackager --site_id <site id> --access_key <access key> --content_id <content id> --hls_ncg ​​-i <input file> -o <output directory>

HLS packaging

FairPlay Streaming DRM-protected HLS stream packaging.

./PallyConPackager --site_id <site id> --access_key <access key> --content_id <content id> --hls ​​-i <input file> -o <output directory>

DASH packaging

PlayReady, Widevine DRM-protected DASH stream packaging.

./PallyConPackager --site_id <site id> --access_key <access key> --content_id <content id> --dash ​​-i <input file> -o <output directory>

NCG packaging

NCG DRM-encoded MP4 file packaging used for download or progressive download scenarios.

./PallyConPackager --site_id <site id> --access_key <access key> --content_id <content id> --ncg ​​-i <input file> -o <output directory>

Adaptive-Streaming packaging

For DASH or HLS packaging, you can enter content with multiple resolutions and package it for adaptive streaming.

./PallyConPackager --site_id <site id> --access_key <access key> --content_id <content id> --dash --hls ​-i <input file1> <input file2> <input file3>​​ -o <output directory>

Using external key (NCG, HLS-NCG)

This is a method of packaging NCG DRM using the key managed by the service site instead of the encryption key generated by PallyCon key server.

./PallyConPackager --site_id <site id> ​--content_id <content id> --enable_raw_key_encryption --ncg_cek <32bytes key> --ncg --hls_ncg ​​-i <input file> -o <output directory>

Using external key (DASH, HLS)

This is a method of multi DRM packaging using the key managed by the service site instead of the encryption key generated by PallyCon key server.

./PallyConPackager ​--content_id <content id> --dash --hls --enable_raw_key_encryption --keys <key pair (e.g. label=:key_id=<16 bytes key id>:key=<16 bytes key>)>​​ -i <input file> -o <output directory>

Using configuration file

It is a method to save fixed setting values among input parameters as a separate config file.

./PallyConPackager ​--config_file <configuration file path>​​ -i <input file> -o <output directory> --content_id <content_id>

Example of config file

  • config.txt (Default = Json)

    {
        "site_id": "your site id",
        "access-key": "your access key"
    }
    
  • config.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <config> 
    <site-id>your site id</site-id> 
    <access-key>your access key</access-key>
    </config>
    

Packaging subtitles

Supports external subtitles in VTT format only.

./PallyConPackager --site_id <site id> --access_key <access key> --content_id <content id> -i <input file> -o <output directory> ​--subtitle <subtitle file path1> ...

Live stream packaging (DASH or HLS)

./PallyConPackager --site_id <site id> --access_key <access key> --content_id <content id>​ ​​-o <output directory> ​--dash(or --hls) -i <input stream (e.g. udp://127.0.0.1:1234)> --preserved_segments_outside_live_window 10 --time_shift_buffer_depth 60
  • Live packaging / playback test can be done by using an web server such as IIS (Windows) and Apache / Nginx (Linux).
  • The only live stream protocol supported by Packager is UDP. If you want to package streams of other unsupported protocols, you can redirect using ffmpeg as follows:
  • # ffmpeg -i <input stream> -f mpegts -vcodec copy -acodec copy udp://127.0.0.1:1234
  • Live streaming environments other than PallyCon Packager should be configured by each service site itself.