Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dlobjoie/96e0965a53a4ac227eeac317078334e2 to your computer and use it in GitHub Desktop.
Save dlobjoie/96e0965a53a4ac227eeac317078334e2 to your computer and use it in GitHub Desktop.
Bash script to create AES-encrypted HLS VOD using ffmpeg. Usage: ./make-encrypted-hls-vod.sh <path to video file>
#!/bin/bash
openssl rand 16 > enc.key
printf "enc.key\nenc.key\n$(openssl rand -hex 16)" > keyinfo.drm
mkdir -p ./hls
ffmpeg -y \
-i "$1" \
-preset slow \
-hls_key_info_file keyinfo.drm \
-hls_time 5 \
-hls_playlist_type vod \
-hls_segment_filename "hls/seg_%d.ts" \
"hls/video.m3u8"
cp enc.key ./hls/enc.key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment