summaryrefslogtreecommitdiff
path: root/_make/video.mk
blob: fc53522cee5e919fb6e0aeb36178ec4c18b30065 (plain)
  1. # Make snippet for rendering development animation
  2. #
  3. # Copyright 2025, Jonas Smedegaard <dr@jones.dk>
  4. # SPDX-License-Identifier: GPL-3-or-later
  5. #
  6. # Setup:
  7. # In main Makefile...
  8. # * optionally set variable VIDEO_FILES
  9. # * optionally set variable VIDEO_TITLE
  10. # * include this make snippet
  11. #
  12. # Dependencies:
  13. # * gource <http://gource.io/>
  14. # * ffmpeg <https://www.ffmpeg.org/>
  15. # * perl
  16. # ffmpeg executable and generic scripting arguments
  17. FFMPEG = ffmpeg -hide_banner -nostdin -y
  18. # title to optionally include in animation
  19. #VIDEO_TITLE =
  20. # list of target animation files
  21. VIDEO_FILES ?= animation.mp4
  22. videos: $(VIDEO_FILES)
  23. %.log:
  24. gource --output-custom-log - | perl -p \
  25. -e 's/(LICENSE|README|txt)\K$$/.plaintext/;' \
  26. -e 's/q?md\K$$/.markdown/;' \
  27. -e 's/(otf|woff2)\K$$/.font/;' \
  28. -e 's/(jpe?g|png)\K$$/.image/;' \
  29. -e 's/(html|pdf|svg)\K$$/.layout/;' \
  30. -e 's/(css|json|gitignore|ya?ml)\K$$/.data/;' \
  31. -e 's/(js|lua|Makefile|mk|rb|rust|scss|sh|tex)\K$$/.code/' \
  32. > $@
  33. %_ffv.mkv: %.log
  34. gource $< -1280x720 -r 25 --multi-sampling \
  35. --disable-input --hide mouse,progress,filenames,bloom \
  36. $(VIDEO_TITLE:%=--title "%") --highlight-users --key \
  37. -o - | $(FFMPEG) -r 25 -f image2pipe -vcodec ppm -i - \
  38. -vcodec ffv1 -level 3 -threads 0 $@
  39. %.mp4: %_ffv.mkv
  40. $(FFMPEG) -i $< -vcodec libx264 -preset slow -pix_fmt yuv420p \
  41. -crf 27 -tune animation -threads 0 -bf 0 $@
  42. %_hevc.mp4: %_ffv.mkv
  43. $(FFMPEG) -i $< -vcodec libx265 -preset slow -pix_fmt yuv420p \
  44. -crf 26 -tune animation -threads 0 -bf 0 $@
  45. %.webm: %_ffv.mkv
  46. $(FFMPEG) -i $< -vcodec libvpx \
  47. -crf 30 -threads 0 -bf 0 $@
  48. %_vp9.webm: %_ffv.mkv
  49. $(FFMPEG) -i $< -vcodec libvpx-vp9 \
  50. -crf 30 -threads 0 -bf 0 $@
  51. %_av1.mkv: %_ffv.mkv
  52. $(FFMPEG) -i $< -vcodec libaom-av1 \
  53. -crf 30 -threads 0 -bf 0 $@
  54. .PHONY: videos