#!/bin/bash

set -e -u

#ATTENTION!
#This script presumes that you have configured an alias for mp4split that automatically includes your license key
#For information on such an alias: http://docs.unified-streaming.com/installation/license.html#license-key-wrapper
#
#USP_LICENSE_KEY=/path/to/ups-license.key
#
# Unified Streaming Platform requires a license key
# Please contact license@unified-streaming.com
if [ -z "${USP_LICENSE_KEY:-}" ]; then
  echo "Missing USP_LICENSE_KEY"
  exit 1
fi
MP4SPLIT="mp4split --license_key=${USP_LICENSE_KEY}"

#Create a server manifest with fMP4 HLS output enabled, including audio, video and text streams
${MP4SPLIT} -o tos-fmp4-hls.ism \
  --hls.fmp4 \
  tears-of-steel-aac-64k.cmfa \
  tears-of-steel-aac-128k.cmfa \
  tears-of-steel-avc1-400k.cmfv \
  tears-of-steel-avc1-750k.cmfv \
  tears-of-steel-avc1-1000k.cmfv \
  tears-of-steel-avc1-1500k.cmfv \
  tears-of-steel-avc1-2200k.cmfv \
  tears-of-steel-hev1-1100k.cmfv \
  tears-of-steel-hev1-1500k.cmfv \
  tears-of-steel-hev1-2200k.cmfv \
  tears-of-steel-en.cmft \
  tears-of-steel-de.cmft
