Created
April 4, 2022 03:24
-
-
Save mreinstein/5ed6bc4e82ce48e58fbcd553b0c568c3 to your computer and use it in GitHub Desktop.
ffmpeg - generate hls videos from an input video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# how to generate hls outputs | |
# from https://ottverse.com/hls-packaging-using-ffmpeg-live-vod/ | |
# had to make a slight adjustment for zsh by wrapping quotes around the -map params, as explained in https://stackoverflow.com/a/60290103/1927767 | |
ffmpeg -i input.mp4 \ | |
-filter_complex \ | |
"[0:v]split=3[v1][v2][v3]; \ | |
[v1]copy[v1out]; [v2]scale=w=960:h=540[v2out]; [v3]scale=w=480:h=270[v3out]" \ | |
-map "[v1out]" -c:v:0 libx264 -x264-params "nal-hrd=cbr:force-cfr=1" -b:v:0 5M -maxrate:v:0 5M -minrate:v:0 5M -bufsize:v:0 10M -preset slow -g 48 -sc_threshold 0 -keyint_min 48 \ | |
-map "[v2out]" -c:v:1 libx264 -x264-params "nal-hrd=cbr:force-cfr=1" -b:v:1 3M -maxrate:v:1 3M -minrate:v:1 3M -bufsize:v:1 3M -preset slow -g 48 -sc_threshold 0 -keyint_min 48 \ | |
-map "[v3out]" -c:v:2 libx264 -x264-params "nal-hrd=cbr:force-cfr=1" -b:v:2 1M -maxrate:v:2 1M -minrate:v:2 1M -bufsize:v:2 1M -preset slow -g 48 -sc_threshold 0 -keyint_min 48 \ | |
-map a:0 -c:a:0 aac -b:a:0 96k -ac 2 \ | |
-map a:0 -c:a:1 aac -b:a:1 96k -ac 2 \ | |
-map a:0 -c:a:2 aac -b:a:2 48k -ac 2 \ | |
-f hls \ | |
-hls_time 2 \ | |
-hls_playlist_type vod \ | |
-hls_flags independent_segments \ | |
-hls_segment_type mpegts \ | |
-hls_segment_filename stream_%v/data%02d.ts \ | |
-master_pl_name master.m3u8 \ | |
-var_stream_map "v:0,a:0 v:1,a:1 v:2,a:2" stream_%v.m3u8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment