推流脚本

#!/bin/bash

serverName="localhost:1935"
basePath="/home/rocdean/nginx"
filePath="/tmp"
HLSPath="/hls"

while getopts :f opt
do
case $opt in
f) force=true;;
*) echo $opt not a option;;
esac
done
shift $[$OPTIND-1]

if [ $force ];then
rm -r $filePath$HLSPath$1
fi

if [ ! -d "$filePath$HLSPath$1" ] && [ ! -f "$filePath$HLSPath$1/index.m3u8" ];then
ffmpeg -re -i $basePath$1.mp4 -vcodec copy -vprofile baseline -acodec copy -f flv rtmp://$serverName$HLSPath$1
echo "#EXT-X-ENDLIST" >> $filePath$HLSPath$1/index.m3u8

else
echo "$filePath$HLSPath$1 OR $filePath$HLSPath$1/index.m3u8 is already exist."
fi

echo "finished~"

原文地址:https://www.cnblogs.com/jiangjing/p/7978705.html