summaryrefslogtreecommitdiff
path: root/bin/decode+edit+encodeDV
blob: 6586b8a3773a24b587554e56698a12a3aba8cfdf (plain)
  1. #!/bin/sh
  2. # FIXME: Handle audio
  3. set -e
  4. INPUT=../src/omni/show0/earth.mp4
  5. LOGO=../../content/icon_small.png
  6. OUTPUT=../tmp/omni/show0/earth.dv
  7. HEIGHT=360
  8. # inspired by Apple HLS recommendations
  9. if [ $HEIGHT -le 234 ]; then
  10. VBITRATE=145000
  11. elif [ $HEIGHT -le 270 ]; then
  12. VBITRATE=365000
  13. elif [ $HEIGHT -le 360 ]; then
  14. VBITRATE=730000
  15. elif [ $HEIGHT -le 432 ]; then
  16. VBITRATE=1100000
  17. elif [ $HEIGHT -le 540 ]; then
  18. VBITRATE=2000000
  19. elif [ $HEIGHT -le 720 ]; then
  20. VBITRATE=3000000
  21. fi
  22. mkdir -p $(dirname "$OUTPUT")
  23. # based on http://www.webmproject.org/docs/encoder-parameters/#real-time-cbr-encoding-and-streaming
  24. # + scale+watermark trick based on http://stackoverflow.com/a/10937357
  25. # + scale to square pixels as needed
  26. # + Add 1s latency (deadline)
  27. ffmpeg -hide_banner -threads auto -y \
  28. -i "$INPUT" \
  29. -i "$LOGO" \
  30. -filter_complex \
  31. "[0:v]scale=iw*sar*$HEIGHT/ih:$HEIGHT,setsar=1[bg];
  32. [bg][1:v]overlay=main_w-overlay_w-20:main_h-overlay_h-20[v]" \
  33. -map '[v]' \
  34. -target pal-dv "$OUTPUT"