Skip to content

Instantly share code, notes, and snippets.

@franzwarning
Created April 9, 2020 00:26
Show Gist options
  • Save franzwarning/f17730482bb4a801d186cbda20b728e0 to your computer and use it in GitHub Desktop.
Save franzwarning/f17730482bb4a801d186cbda20b728e0 to your computer and use it in GitHub Desktop.
ffmpeg rtmp input to hls recording (with audio only rendition) w/ filter complex to square
ffmpeg -t 00:01:00 -i rtmp://localhost:1935/live/stream -y \
-filter_complex '[0:v]crop=if(gte(iw\,ih)\,ih\,iw):if(gte(iw\,ih)\,ih\,iw),split=4[out1][out2][out3][out4]' \
\
-map '[out1]' -map 0:a \
-map '[out2]' -map 0:a \
-map '[out3]' -map 0:a \
-map '[out4]' -map 0:a \
-map 0:a \
\
-s:v:0 1080x1080 -c:v:0 libx264 -b:v:0 4500k \
-s:v:1 720x720 -c:v:1 libx264 -b:v:1 2500k \
-s:v:2 480x480 -c:v:2 libx264 -b:v:2 1250k \
-s:v:3 240x240 -c:v:3 libx264 -b:v:3 400k \
\
-c:a copy \
-var_stream_map "v:0,a:0,name:1080 v:1,a:1,name:720 v:2,a:2,name:480 v:3,a:3,name:240 a:4,name:audio" \
\
-master_pl_name master.m3u8 \
-f hls -hls_time 6 -hls_list_size 0 \
-crf 20 -sc_threshold 0 -g 60 -keyint_min 48 -hls_time 4 \
-hls_segment_filename "%v/fileSequence%d.ts" \
%v/prog_index.m3u8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment