Encore packager

February 16, 2026 · View on GitHub


Quick Demo: Open Source Cloud

Run this service in the cloud with a single click.

Badge OSC


Wrapper for packaging output of an encore transcoding job with Shaka Packager.

Can be run either as a CLI or as a service. In the latter case it will listen for messages on a redis queue and package the output of the transcoding job referenced by the message.

The packager supports two modes of operation:

  • Standard mode: Package video files using Shaka Packager for DASH/HLS output
  • Skip packaging mode: Copy source MP4 files and generate SMIL playlists for direct streaming

Requirements

shaka packager needs to be installed for standard packaging mode. Unless the shaka executable is named packager and is in PATH, the path to the executable must be provided as an environment variable SHAKA_PACKAGER_EXECUTABLE.

Note: Shaka Packager is not required when using skip packaging mode (--skip-packaging or SKIP_PACKAGING=true).

Usage

CLI

Standard Packaging Mode

# Package files with Shaka Packager (default behavior)
encore-packager -u https://encore.example.com/api/encoreJobs/123

Skip Packaging Mode

# Copy MP4 files and generate SMIL playlist
encore-packager -u https://encore.example.com/api/encoreJobs/123 --skip-packaging

# Using short option
encore-packager -u https://encore.example.com/api/encoreJobs/123 -s

# Using environment variable
SKIP_PACKAGING=true encore-packager -u https://encore.example.com/api/encoreJobs/123

In skip packaging mode, the tool will:

  • Copy all MP4 video files from the Encore job output
  • Generate a SMIL playlist file (playlist.smil) with bitrate information
  • Support both local file copying and HTTP(S) URL downloading
  • Create the same output folder structure as standard packaging mode

Running as a service

When running as a service, the packager can be configured to use skip packaging mode for all jobs by setting the SKIP_PACKAGING environment variable.

# Standard packaging mode (default)
npm run start

# Skip packaging mode for all jobs
SKIP_PACKAGING=true npm run start

Environment variables

VariableDescriptionDefault value
REDIS_URLURL to the redis serverredis://localhost:6379
REDIS_QUEUEName of the redis queue to listen topackaging-queue
HOSTHostname or IP address to bind to for healtchechk endpoint0.0.0.0
PORTPort to bind to for healtchechk endpoint8000
DISABLE_HEALTCHECKDisable the healthcheck endpointfalse
SHAKA_PACKAGER_EXECUTABLEPath to the shaka packager executablepackager
PACKAGE_OUTPUT_FOLDERBase folder for output, actual output will be in a subfolder according to OUTPUT_SUBFOLDER_TEMPLATEpackaged
PACKAGE_CONCURRENCYNumber of concurrent packaging jobs1
PACKAGE_LISTENER_PLUGINOptional path to a javascript file containing a custom listener for packaging event, see below
PACKAGE_FORMAT_OPTIONS_JSONOptional JSON string with format options for shaka packager, format as defined in https://github.com/Eyevinn/shaka-packager-s3/blob/main/src/packager.ts
VIDEO_STREAM_KEY_TEMPLATEOptional template for video stream key, see below for supported keywords$VIDEOIDX$_$BITRATE$
AUDIO_STREAM_KEY_TEMPLATEOptional template for video stream key, see below for supported keywords$AUDIOIDX$
OUTPUT_SUBFOLDER_TEMPLATETemplate for subfolder relative to PACKAGE_OUTPUT_FOLDER where output will be stored. Keywords $INPUTNAME$, $JOBID$, and $EXTERNALID$ will be replaced with basename of input, id, and external id of encore job respectively$INPUTNAME$/$JOBID$
DASH_MANIFEST_NAME_TEMPLATETemplate for name of DASH manifest file. Keywords $INPUTNAME$ and $JOBID$ will be replaced with basename of input, and id of encore job respectively. If unset, uses default from shaka-packager-s3 library manifest.mpd
HLS_MANIFEST_NAME_TEMPLATETemplate for name of HLS manifest file. Keywords $INPUTNAME$ and $JOBID$ will be replaced with basename of input, and id of encore job respectively. If unset, uses default from shaka-packager-s3 library, index.m3u8
ENCORE_PASSWORDOptional password for the encore instance user user
OSC_ACCESS_TOKENOptional OSC access token for accessing Encore instance in OSC
AWS_ACCESS_KEY_IDOptional AWS access key id when PACKAGE_OUTPUT_FOLDER is an AWS S3 bucket
AWS_SECRET_ACCESS_KEYOptional AWS secret access key when PACKAGE_OUTPUT_FOLDER is an AWS S3 bucket
S3_ENDPOINT_URLOptional S3 Endpoint URL when PACKAGE_OUTPUT_FOLDER is an S3 bucket not on AWS
CALLBACK_URLOptional callback service url. If enabled, the packager will send callbacks on packaging success or failure. To use baisc auth, provide the URL in the format https://user:password@hostname/path
SKIP_PACKAGINGSkip Shaka Packager and copy MP4 files with SMIL generation instead. Set to true to enablefalse
SMIL_BASE_URLOptional base URL to include in generated SMIL files. Used for resolving relative video file paths
Stream key templates

Stream key templates can be used to set the 'key' for each stream, which decides how the stream is identified in the packaged manifest.

Keywords in the template are replaced with values according to the table below.

KeywordValue
$VIDEOIDX$Video stream index, starting from 0
$AUDIOIDX$Audio stream index, starting from 0
$TOTALIDX$Total stream index. For video streams, this is the video stream index. For Audio streams, this is audio stream index plus number of video streams
$BITRATE$Bitrate of the stream

SMIL Output Format (Skip Packaging Mode)

When using skip packaging mode, a SMIL (Synchronized Multimedia Integration Language) file is generated alongside the copied MP4 files. The SMIL file provides a playlist format that can be used for adaptive bitrate streaming.

Example SMIL output structure:

output-folder/
├── video_1080p.mp4
├── video_720p.mp4
├── video_480p.mp4
└── playlist.smil

Example SMIL file content:

<?xml version="1.0" encoding="UTF-8"?>
<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
  <head>
    <meta base="https://example.com/videos/" />
  </head>
  <body>
    <switch>
      <video src="video_1080p.mp4" system-bitrate="5000000" />
      <video src="video_720p.mp4" system-bitrate="3000000" />
      <video src="video_480p.mp4" system-bitrate="1500000" />
    </switch>
  </body>
</smil>

The SMIL file includes:

  • Bitrate information for each video rendition
  • Base URL for resolving relative paths (configurable via SMIL_BASE_URL)
  • Standard SMIL switch element for adaptive playback

Starting the service

npm run start

Custom packager listener

To implement a custom listener that reacts to package events, provide a path to a javascript file in the PACKAGE_LISTENER_PLUGIN environment variable. Example file below, not all methods need to be defined.

export function onPackageDone(url) {
  console.log(`Package done: ${url}`);
}

export function onPackageFail(msg, err) {
  console.log(`Package fail: ${msg}, ${err.message}`);
}

export function onPackageStart(url) {
  console.log(`Package start: ${url}`);
}

Contributing

See CONTRIBUTING

Support

Join our community on Slack where you can post any questions regarding any of our open source projects. Eyevinn's consulting business can also offer you:

  • Further development of this component
  • Customization and integration of this component into your platform
  • Support and maintenance agreement

Contact sales@eyevinn.se if you are interested.

About Eyevinn Technology

Eyevinn Technology is an independent consultant firm specialized in video and streaming. Independent in a way that we are not commercially tied to any platform or technology vendor. As our way to innovate and push the industry forward we develop proof-of-concepts and tools. The things we learn and the code we write we share with the industry in blogs and by open sourcing the code we have written.

Want to know more about Eyevinn and how it is to work here. Contact us at work@eyevinn.se!