Skip to content

Shaka Packager Integration Guide

This guide explains how to encrypt media content using DoveRunner’s key management service (KMS) with Shaka Packager, Google’s open-source media packaging tool. The integration supports multiple DRM systems including Widevine, PlayReady, and FairPlay.

Based on Shaka Packager, DoveRunner provides two packaging options. Choose based on your needs:

FeatureShaka Packager IntegrationDRM CLI Packager
Best forDevelopers with existing Shaka workflowsQuick setup without additional configuration
FlexibilityFull access to all Shaka Packager featuresPre-configured for common use cases
SetupRequires Python environment and manual configurationStandalone executable, minimal setup
CustomizationMaximum control over packaging parametersSimplified options for standard scenarios
UpdatesUse latest Shaka Packager versions independentlyManaged releases tested for DoveRunner compatibility

Before you begin, ensure you have the following:

RequirementDetails
PythonVersion 3.6 or later
DoveRunner accountActive subscription with KMS access
Encryption tokenGenerated from the DoveRunner Console

You will also need to download these components:

  1. Clone the integration sample repository:

    Terminal window
    git clone https://github.com/doverunner/shaka-packager-integration-sample
    cd shaka-packager-integration-sample
  2. Clone the CPIX API client into the same directory:

    Terminal window
    git clone https://github.com/doverunner/cpix-api-client.git
  3. Download and place the Shaka Packager binary in the project directory.

Your directory structure should look like this:

shaka-packager-integration-sample/
├── cpix-api-client/
├── doverunner-integration-script.py
└── packager-win-x64.exe (or platform equivalent)

Run the integration script with the following syntax:

Terminal window
python3 doverunner-integration-script.py \
--enc_token <token> \
--content_id <id> \
--drm_type <types> \
[options] \
[shaka_packager_args]
ArgumentDescription
--enc_tokenYour DoveRunner KMS encryption token for CPIX API authentication
--content_idUnique identifier for your content. This ID must match the content ID used in DRM license request tokens
--drm_typeComma-separated list of DRM systems: widevine, playready, fairplay
ArgumentDescriptionDefault
--encryption_schemeEncryption mode: cenc, cbc1, cens, or cbcscenc
--track_typeComma-separated track types: all_tracks, audio, sd, hd, uhd1, uhd2all_tracks

All arguments not listed above are passed directly to Shaka Packager. Refer to the Shaka Packager documentation for available options.

The following example encrypts an H.264 video file with Widevine and PlayReady DRM, outputting a DASH manifest:

Terminal window
python3 doverunner-integration-script.py \
--enc_token your-enc-token \
--content_id movie123 \
--drm_type widevine,playready \
'in=h264_720p.mp4,stream=video,init_segment=output/video/init.mp4,segment_template=output/video/$Number$.m4s' \
'in=h264_720p.mp4,stream=audio,init_segment=output/audio/init.mp4,segment_template=output/audio/$Number$.m4s' \
--generate_static_live_mpd \
--mpd_output output/stream.mpd \
--clear_lead 0

This command:

  • Retrieves Widevine and PlayReady keys from DoveRunner KMS
  • Encrypts video and audio streams separately
  • Generates segmented output in the output/ directory
  • Creates a DASH manifest at output/stream.mpd
  • Sets clear_lead to 0, ensuring all content is encrypted from the start

When you run the integration script:

  1. The script authenticates with DoveRunner KMS using your encryption token
  2. It requests content keys for the specified DRM systems via the CPIX API
  3. The script constructs a Shaka Packager command with the encryption keys and your parameters
  4. Shaka Packager executes the packaging operation, encrypting your content with the specified DRM protection
  5. The encrypted output files are written to your specified locations
IssueSolution
Authentication errorsVerify your --enc_token is valid and has not expired
Content ID mismatchEnsure the --content_id matches the ID configured in your license tokens
Binary not foundConfirm the Shaka Packager executable is in the script directory and has execute permissions
Unsupported DRM typeCheck that you spelled the DRM type correctly: widevine, playready, or fairplay