From fa117207427b661e06cdb13a676df3784512176c Mon Sep 17 00:00:00 2001 From: mattmcw Date: Sun, 9 May 2021 09:11:54 -0400 Subject: [PATCH] Add an example for RTMP live streaming --- stream/rtmp.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 stream/rtmp.sh diff --git a/stream/rtmp.sh b/stream/rtmp.sh new file mode 100644 index 0000000..2070138 --- /dev/null +++ b/stream/rtmp.sh @@ -0,0 +1,39 @@ +#!/bin/bash -e + +##################################################### +# +# This script will stream a video to an RTMP ingestion +# server that accepts H264 encoding. Can be used for +# live streaming services. +# +# Usage: bash stream/rtmp.sh +# +##################################################### + +INPUT="${1}" +RTMP="${2}" + +# Check if input and output arguments are supplied +if [ "${INPUT}" == "" ] || [ "${OUTPUT}" == "" ]; then + echo "Please provide input and output files as your first and second arguments" + exit 1 +fi + +# Check if RTMP url is provided +if [[ "${RTMP}" == "" ]]; then + echo "Please provide an RTMP url" + exit 2 +fi + +ffmpeg -re -i "${INPUT}"-c:v libx264 \ + -preset veryfast \ + -maxrate 2048k \ + -bufsize 4096k \ + -pix_fmt yuv420p \ + -g 60 \ + -c:a aac \ + -b:a 190k \ + -ac 2 \ + -ar 44100 \ + -f flv \ + "${RTMP}"