Skip to content

Instantly share code, notes, and snippets.

@arafathusayn
Last active May 13, 2022 20:59
Show Gist options
  • Save arafathusayn/cf7add0eb02cb68ba328e0b390f69c61 to your computer and use it in GitHub Desktop.
Save arafathusayn/cf7add0eb02cb68ba328e0b390f69c61 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)" > enc.keyinfo
mkdir -p ./hls
ffmpeg -y \
-i "$1" \
-preset ultrafast \
-hls_key_info_file enc.keyinfo \
-hls_time 10 \
-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