Created
May 7, 2024 15:32
-
-
Save badpenguin/9246a04cc7d54669817f50a3e2c9c196 to your computer and use it in GitHub Desktop.
This portion of script downscale your video to 4 video formats and create all the HLS playlist. Then you can host the files on your servers and use VideoJS, Shaka and others as a player.
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
OPT="-c:a aac -ar 48000 -c:v libx264 -profile:v main -preset veryfast -tune fastdecode -crf 21 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 6 -hls_playlist_type vod -hls_flags independent_segments -hls_segment_type mpegts -hls_list_size 0" | |
ffmpeg \ | |
-hide_banner -loglevel warning -stats \ | |
-threads 8 -hwaccel vdpau \ | |
-y -i "$IFILE" \ | |
$OPT \ | |
-map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 \ | |
-filter:v:0 scale=w=640:h=360:force_original_aspect_ratio=decrease:force_divisible_by=2 -b:v:0 800k -maxrate:v:0 856k -bufsize:v:0 1200k -b:a:0 96k \ | |
-filter:v:1 scale=w=842:h=480:force_original_aspect_ratio=decrease:force_divisible_by=2 -b:v:1 1400k -maxrate:v:1 1498k -bufsize:v:1 2100k -b:a:1 128k \ | |
-filter:v:2 scale=w=1280:h=720:force_original_aspect_ratio=decrease:force_divisible_by=2 -b:v:2 2800k -maxrate:v:2 2996k -bufsize:v:2 4200k -b:a:2 128k \ | |
-filter:v:3 scale=w=1920:h=1080:force_original_aspect_ratio=decrease:force_divisible_by=2 -b:v:3 5000k -maxrate:v:3 5350k -bufsize:v:3 7500k -b:a:3 192k \ | |
-master_pl_name master.m3u8 \ | |
-var_stream_map "v:0,a:0,name:360p v:1,a:1,name:480p v:2,a:2,name:720p v:3,a:3,name:1080p" \ | |
-hls_segment_filename "%v/%03d.ts" "%v/index.m3u8" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment