Skip to content

Instantly share code, notes, and snippets.

@jamesjennings
Created September 18, 2013 18:09
Show Gist options
  • Save jamesjennings/6613083 to your computer and use it in GitHub Desktop.
Save jamesjennings/6613083 to your computer and use it in GitHub Desktop.
Script for transcoding, segmenting and preparing a video file for HLS playback. Used as a demo at 360iDev Denver 2013. Depends on HandBrakeCLI (from http://handbrake.fr/downloads2.php) and Apple's HLS tools (from https://developer.apple.com/streaming/)
HandBrakeCLI --input tears_of_steel_720p.mkv --output 5000.mp4 --encoder x264 -b 5000 --srt-file TOS-en.srt --x264-preset ultrafast
HandBrakeCLI --input tears_of_steel_720p.mkv --output 500.mp4 --encoder x264 -b 500 --srt-file TOS-en.srt --x264-preset ultrafast
HandBrakeCLI --input tears_of_steel_720p.mkv --output 50.mp4 --encoder x264 -b 50 --srt-file TOS-en.srt --x264-preset ultrafast
HandBrakeCLI --input tears_of_steel_720p.mkv --output 5.mp4 --encoder x264 -b 5 --srt-file TOS-en.srt --x264-preset ultrafast
mkdir 5000Kbps
mediafilesegmenter -t 10 -f 5000Kbps/ -I 5000.mp4
mkdir 500Kbps
mediafilesegmenter -t 10 -f 500Kbps/ -I 500.mp4
mkdir 50Kbps
mediafilesegmenter -t 10 -f 50Kbps/ -I 50.mp4
mkdir 5Kbps
mediafilesegmenter -t 10 -f 5Kbps/ -I 5.mp4
variantplaylistcreator -o final.m3u8 50Kbps/prog_index.m3u8 50.plist -iframe-url 50Kbps/iframe_index.m3u8 \
5000Kbps/prog_index.m3u8 5000.plist -iframe-url 5000Kbps/iframe_index.m3u8 \
500Kbps/prog_index.m3u8 500.plist -iframe-url 500Kbps/iframe_index.m3u8 \
5Kbps/prog_index.m3u8 5.plist -iframe-url 5Kbps/iframe_index.m3u8
@HarrisonJackson
Copy link

This is awesome - thanks for getting back to my tweet. I used something similar to play dvds on an ipad and appletv - but it was a very hacked together VLC script and I didn't even know Handbrake had any command line scripts. I'll have to dig deeper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment