summaryrefslogtreecommitdiff
path: root/bin/stream.sh
blob: 01ef12da473ec3516cd920dc0cabd105a1ec790c (plain)
  1. #!/bin/sh
  2. set -e
  3. HOST=${1:-morla}
  4. if [ "$HOST" = "$(hostname --short)" ]; then
  5. IP=127.0.0.1
  6. else
  7. IP=$(host "$HOST" | grep -Po 'address \K\S+')
  8. fi
  9. PORT=${2:-5004}
  10. SIZE=640x360
  11. MOVIE=../src/omni/show0/earth.mp4
  12. LOGO=../../content/icon_small.png
  13. # based on http://video.stackexchange.com/a/16933
  14. # + codec options from http://www.webmproject.org/docs/encoder-parameters/
  15. # example "Real-time CBR Encoding and Streaming"
  16. # (bufsize = 6000 * 500k / 1000)
  17. # (rc_init_occupancy = 4000 * 500k / 1000)
  18. # + Drop frames, aggressively treat as static, and use fastest cpu
  19. ffmpeg -threads auto -re \
  20. -f lavfi -i "movie=filename=$MOVIE:loop=0, setpts=N/(FRAME_RATE*TB), scale=$SIZE" \
  21. -i "$LOGO" -filter_complex 'overlay=main_w-overlay_w-20:main_h-overlay_h-20' \
  22. -codec:v vp8 -quality realtime -deadline realtime -cpu-used 15 \
  23. -b:v 500k -minrate 500k -maxrate 500k \
  24. -undershoot-pct 95 -bufsize 3M -rc_init_occupancy 2M \
  25. -max-intra-rate 0 \
  26. -qmin 4 -qmax 56 \
  27. -static-thresh 500 -skip_threshold 50 \
  28. -an -f rtp "rtp://$IP:$PORT?pkt_size=1200"