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