-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbroadcast
executable file
·60 lines (51 loc) · 1.53 KB
/
broadcast
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
#
# broadcast
# =========
# This is script which broadcast with ffmpeg.
# Sorry, this is for Linix only.
# # Required extra tools:
# - ffmpeg ver.N-37669 or later (compiling with librtmp, libx264 and libfaac)
#
RTMP_URI="$1"
STREAM="$2"
SCRIPTDIR=$(cd -P $(dirname "$0") && pwd -P)
DESTDIR=${DESTDIR:-$SCRIPTDIR}
# --- Load config files
if [ -e ${SCRIPTDIR}/config/global.conf ]; then
. ${SCRIPTDIR}/config/global.conf || exit 1
else
echo "Can't open config/global file." >2
exit 1
fi
BC_CONFFILE="${SCRIPTDIR}/config/broadcast.d/${BROADCASTER}.conf"
if [ -e "${BC_CONFFILE}" ]; then
. ${BC_CONFFILE}
else
echo "Can't open ${BC_CONFFILE}" >2
exit 2
fi
# --- Adjust parameter
if [ "${RTMP_URI}" = "test" ]; then
FULL_OUTPUT_URI="${DESTDIR}/test.flv"
else
if [ -z "${STREAM}" ]; then
echo "Please specified RTMP_URI and STREAM."
exit 3
fi
OUTPUT_URI="${RTMP_URI}/${STREAM}"
RTMPPARAMS=$(echo "$RTMPPARAMS" | sed -e "s#@@RTMPURI@@#${OUTPUT_URI}#g")
FULL_OUTPUT_URI="${OUTPUT_URI} ${RTMPPARAMS}"
fi
# --- Muxing video/audio and streaming to server.
FFMPEGFULLCOMMAND="${FFMPEG} -y
${FFMPEGDEBUG} -threads ${FFMPEGTHREADS}
-f ${VIDEO_SRC_FMT} -i ${VIDEO_SRC_DEV}
-f ${AUDIO_SRC_FMT} -i ${AUDIO_SRC_DEV}
${VCODEC_OPTS} ${ACODEC_OPTS} \
${OUTPUT_OPTS} ${FULL_OUTPUT_URI}"
/bin/echo -e "FFMPEG Command:\n" $FFMPEGFULLCOMMAND
exec $FFMPEGFULLCOMMAND
# ${OUTPUT_OPTS} pipe: \
# | ${FFMPEG} -y -re -i - -codec copy -f flv "${FULL_OUTPUT_URI}" \
# -codec copy output.flv