summaryrefslogtreecommitdiff
path: root/bin/decode+edit+encode
blob: 72ef4cd182d91202d0f12855ceb0df29b3c7fe23 (plain)
  1. #!/bin/sh
  2. set -e
  3. ITERATIONS=${1-1} # no looping by default
  4. HEIGHT=360
  5. VBITRATE=500000
  6. MOVIE=../src/omni/show0/earth.mp4
  7. LOGO=../../content/icon_small.png
  8. TMPMOVIE=../tmp/omni/show0/earth.webm
  9. mkdir -p $(dirname "$TMPMOVIE")
  10. # based on http://www.webmproject.org/docs/encoder-parameters/#real-time-cbr-encoding-and-streaming
  11. # + loop-in-filter trick based on http://video.stackexchange.com/a/16933
  12. # + scale+watermark trick based on http://stackoverflow.com/a/10937357
  13. ffmpeg -threads auto -y -re \
  14. -f lavfi -i "movie=filename=$MOVIE:loop=$ITERATIONS, setpts=N/(FRAME_RATE*TB)" \
  15. -i "$LOGO" \
  16. -filter_complex \
  17. "[0:v]scale=-1:$HEIGHT[bg];
  18. [bg][1:v]overlay=main_w-overlay_w-20:main_h-overlay_h-20" \
  19. -an \
  20. -codec:v vp8 -quality realtime -deadline realtime -cpu-used 4 \
  21. -b:v "$VBITRATE" -minrate "$VBITRATE" -maxrate "$VBITRATE" \
  22. -undershoot-pct 95 -bufsize $((6000*VBITRATE/1000)) -rc_init_occupancy $((4000*VBITRATE/1000)) \
  23. -max-intra-rate 0 \
  24. -qmin 4 -qmax 56 \
  25. -f webm "$TMPMOVIE"