Skip to content

Instantly share code, notes, and snippets.

@cbaltzer
Created August 16, 2022 19:23
Show Gist options
  • Save cbaltzer/d8d16051fb570ae9a767c9a1161f7050 to your computer and use it in GitHub Desktop.
Save cbaltzer/d8d16051fb570ae9a767c9a1161f7050 to your computer and use it in GitHub Desktop.
#!/bin/bash
ENCODER=h264_videotoolbox
if [[ -n "$1" ]]
then
ENCODER=$1
fi
#
# Get the test video
# http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
#
if [[ ! -f "BigBuckBunny.mp4" ]]
then
curl http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 --output BigBuckBunny.mp4
fi
#
# Setup output dir
#
rm -rf benchmark_out/
mkdir -p benchmark_out
#
# Transcode the baby
#
ffmpeg -nostdin -loglevel info -i BigBuckBunny.mp4 \
-filter_complex \
"[0:v]split=3[v1][v2][v3]; [v1]copy[v1out]; [v2]scale=w=-2:h=720[v2out]; [v3]scale=w=-2:h=360[v3out]" \
-map "[v1out]" -c:v:0 $ENCODER -b:v:0 10000k -maxrate:v:0 12000k -minrate:v:0 8000k -bufsize:v:0 15000k -g 48 -keyint_min 48 \
-map "[v2out]" -c:v:1 $ENCODER -b:v:1 6000k -maxrate:v:1 7000k -minrate:v:1 5000k -bufsize:v:1 9M -g 48 -keyint_min 48 \
-map "[v3out]" -c:v:2 $ENCODER -b:v:2 1500k -maxrate:v:2 2000k -minrate:v:2 1000k -bufsize:v:2 2500k -g 48 -keyint_min 48 \
-map a:0 -c:a:0 aac -b:a:0 192k -ac 2 \
-map a:0 -c:a:1 aac -b:a:1 128k -ac 2 \
-map a:0 -c:a:2 aac -b:a:2 96k -ac 2 \
-f hls \
-hls_time 6 \
-hls_playlist_type vod \
-hls_flags independent_segments \
-hls_segment_type mpegts \
-hls_segment_filename benchmark_out/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" benchmark_out/stream_%v/stream.m3u8 > benchmark_result.txt 2>&1
#
# Cleanup
#
rm -rf benchmark_out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment