summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-04 18:32:23 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-04 18:32:23 +0200
commite7a3f676262d58dc0e9d48a0c8b12ca4b507177d (patch)
tree8be5a902ce2581872ca531670f6e2bf505171b80 /bin
parent28af1f773e39a91891fa31470fdd0e42bf7e206b (diff)
Add MPEG (H.264/AAC) encoding, and switch variable MKMPEG.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/stream19
1 files changed, 16 insertions, 3 deletions
diff --git a/bin/stream b/bin/stream
index 0236af7..38902d2 100755
--- a/bin/stream
+++ b/bin/stream
@@ -68,7 +68,7 @@ fi
VSTREAMINDEX=1
[ -n "$AINPUT" ] || VSTREAMINDEX=0
-FIRSTPORT=${FIRSTPORT:-5002} # even number - next 3 ports used too
+FIRSTPORT=${FIRSTPORT:-5002} # even number - next 7 ports used too
ACHANNELS=2
AFRAMERATE=48000
@@ -78,8 +78,10 @@ HEIGHT=360
VBITRATE=256000
MKWEBM='[webm]'
+MKMPEG='[mpeg]'
[ -z "$MKWEBM" ] || VCODECCOUNT=$((VCODECCOUNT+1))
+[ -z "$MKMPEG" ] || VCODECCOUNT=$((VCODECCOUNT+1))
SAVESTEM="$SAVEDIR/$(date +%Y%m%d-%H%M%S)"
${SAVEDIR:+export FFREPORT=file="$SAVESTEM.log"}
@@ -99,7 +101,7 @@ ffmpeg -hide_banner -threads auto -re \
${HASVIDEO:+-filter_complex \
"[$VSTREAMINDEX:v]scale=-2:$HEIGHT${WATERMARK:-[v]}${WATERMARK:+[bg]${LOGO:+;
[bg][$((VSTREAMINDEX+1)):v]overlay=main_w-overlay_w-20:main_h-overlay_h-20[v]}};
- [v]split=$VCODECCOUNT$MKWEBM" } \
+ [v]split=$VCODECCOUNT$MKWEBM$MKMPEG" } \
${SAVEDIR:+-map '0:' ${TWOSOURCES:+-map '1:'} \
-codec copy \
-f segment -segment_format matroska -segment_format_options live=1:reserve_index_space=512kB \
@@ -118,4 +120,15 @@ ffmpeg -hide_banner -threads auto -re \
-qmin 4 -qmax 56 } \
-f tee \
"${HASAUDIO:+[select=\'a\':f=rtp:payload_type=111]rtp://$IP:$FIRSTPORT?pkt_size=1200| \
- }${HASVIDEO:+[select=\'v\':f=rtp:payload_type=100]rtp://$IP:$((FIRSTPORT+2))?pkt_size=1200}" }
+ }${HASVIDEO:+[select=\'v\':f=rtp:payload_type=100]rtp://$IP:$((FIRSTPORT+2))?pkt_size=1200}" } \
+ ${MKMPEG:+\
+ ${HASAUDIO:+-map '0:a' } ${HASVIDEO:+-map '[mpeg]' } \
+ ${HASAUDIO:+\
+ -codec:a aac -strict experimental -ac "$ACHANNELS" -ar 44100 -b:a $((ACHANNELS*64))k } \
+ ${HASVIDEO:+\
+ -pix_fmt yuv420p \
+ -codec:v libx264 -tune zerolatency -preset ultrafast \
+ -maxrate "$VBITRATE" -bufsize "$((VBITRATE*2))" -crf 23 } \
+ -f tee \
+ "${HASAUDIO:+[select=\'a\':f=rtp:payload_type=96]rtp://$IP:$((FIRSTPORT+4))?pkt_size=1200| \
+ }${HASVIDEO:+[select=\'v\':f=rtp:payload_type=97]rtp://$IP:$((FIRSTPORT+6))?pkt_size=1200}" }