unix4artists/stream/rtmp.sh

41 lines
851 B
Bash

#!/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 video> <rtmp url>
#
#####################################################
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}"