diff options
author | Jonas Smedegaard <dr@jones.dk> | 2017-05-18 09:39:53 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2017-05-18 09:39:53 +0200 |
commit | cdbf4dee39cdd3dc083299d88d619effc1e72e14 (patch) | |
tree | 9b075856b46cdb4a764791c3d9e2afaa0fdc704b /bin/loop+encode+stream | |
parent | 39bc48eb0e8b9a2b8d43d6f1a612c12d0c70ae23 (diff) |
Generalize encodings as functions.
Diffstat (limited to 'bin/loop+encode+stream')
-rwxr-xr-x | bin/loop+encode+stream | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/bin/loop+encode+stream b/bin/loop+encode+stream index 3906552..5893ed3 100755 --- a/bin/loop+encode+stream +++ b/bin/loop+encode+stream @@ -55,6 +55,17 @@ elif [ $BITS -le 921600 ]; then # 720p → 921600 SPEED_VP8=15 fi +encode_opus() { + echo_n "-codec:a libopus -ac $ACHANNELS -ar $AFRAMERATE_OPUS -b:a $ABITRATE_OPUS" +} +encode_vp8() { bitrate=$1; speed=$2; + echo_n "-codec:v vp8 -quality realtime -deadline 1000000 -cpu-used $speed \ + -b:v $bitrate -minrate $bitrate -maxrate $bitrate \ + -undershoot-pct 95 -bufsize $((6000*bitrate/1000)) -rc_init_occupancy $((4000*bitrate/1000)) \ + -max-intra-rate 0 \ + -qmin 4 -qmax 56" +} + # based on http://www.webmproject.org/docs/encoder-parameters/#real-time-cbr-encoding-and-streaming # + Add 1s latency (deadline) # + Use same RTP payload types as GStreamer @@ -62,12 +73,8 @@ ffmpeg -hide_banner -threads auto -re \ -stream_loop -1 -i "$INPUT" \ -vf format=pix_fmts=yuv420p \ -map '0:a' \ - -codec:a libopus -ac "$ACHANNELS" -ar "$AFRAMERATE_OPUS" -b:a "$ABITRATE_OPUS" \ + $(encode_opus) \ -f rtp -payload_type 111 "rtp://$IP:$FIRSTPORT?pkt_size=1200" \ -map '0:v' \ - -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used "$SPEED_VP8" \ - -b:v "$VBITRATE" -minrate "$VBITRATE" -maxrate "$VBITRATE" \ - -undershoot-pct 95 -bufsize $((6000*VBITRATE/1000)) -rc_init_occupancy $((4000*VBITRATE/1000)) \ - -max-intra-rate 0 \ - -qmin 4 -qmax 56 \ + $(encode_vp8 "$VBITRATE" "$SPEED_VP8") \ -f rtp -payload_type 100 "rtp://$IP:$((FIRSTPORT+2))?pkt_size=1200" |