summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-05-30 13:03:37 +0200
committerJonas Smedegaard <dr@jones.dk>2025-06-07 08:55:45 +0200
commit941e20f1cbc130cedb5adaabf76fad1f530f0bd9 (patch)
tree2f0b534e9743e51e67ec7d440a47db14e0f984b3
parenta90ff569147123a4bd648dcee1360cd07eb671bf (diff)
add make snippet video
-rw-r--r--Makefile5
-rw-r--r--_make/video.mk66
2 files changed, 71 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index c70939f..57e3cf6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,8 @@
+VIDEO_TITLE = https://posten.orø.dk/
+VIDEO_FILES = posten.mp4 posten.webm
+
+include _make/*.mk
+
all: preview
preview:
diff --git a/_make/video.mk b/_make/video.mk
new file mode 100644
index 0000000..fc53522
--- /dev/null
+++ b/_make/video.mk
@@ -0,0 +1,66 @@
+# Make snippet for rendering development animation
+#
+# Copyright 2025, Jonas Smedegaard <dr@jones.dk>
+# SPDX-License-Identifier: GPL-3-or-later
+#
+# Setup:
+# In main Makefile...
+# * optionally set variable VIDEO_FILES
+# * optionally set variable VIDEO_TITLE
+# * include this make snippet
+#
+# Dependencies:
+# * gource <http://gource.io/>
+# * ffmpeg <https://www.ffmpeg.org/>
+# * perl
+
+# ffmpeg executable and generic scripting arguments
+FFMPEG = ffmpeg -hide_banner -nostdin -y
+
+# title to optionally include in animation
+#VIDEO_TITLE =
+
+# list of target animation files
+VIDEO_FILES ?= animation.mp4
+
+videos: $(VIDEO_FILES)
+
+%.log:
+ gource --output-custom-log - | perl -p \
+ -e 's/(LICENSE|README|txt)\K$$/.plaintext/;' \
+ -e 's/q?md\K$$/.markdown/;' \
+ -e 's/(otf|woff2)\K$$/.font/;' \
+ -e 's/(jpe?g|png)\K$$/.image/;' \
+ -e 's/(html|pdf|svg)\K$$/.layout/;' \
+ -e 's/(css|json|gitignore|ya?ml)\K$$/.data/;' \
+ -e 's/(js|lua|Makefile|mk|rb|rust|scss|sh|tex)\K$$/.code/' \
+ > $@
+
+%_ffv.mkv: %.log
+ gource $< -1280x720 -r 25 --multi-sampling \
+ --disable-input --hide mouse,progress,filenames,bloom \
+ $(VIDEO_TITLE:%=--title "%") --highlight-users --key \
+ -o - | $(FFMPEG) -r 25 -f image2pipe -vcodec ppm -i - \
+ -vcodec ffv1 -level 3 -threads 0 $@
+
+%.mp4: %_ffv.mkv
+ $(FFMPEG) -i $< -vcodec libx264 -preset slow -pix_fmt yuv420p \
+ -crf 27 -tune animation -threads 0 -bf 0 $@
+
+%_hevc.mp4: %_ffv.mkv
+ $(FFMPEG) -i $< -vcodec libx265 -preset slow -pix_fmt yuv420p \
+ -crf 26 -tune animation -threads 0 -bf 0 $@
+
+%.webm: %_ffv.mkv
+ $(FFMPEG) -i $< -vcodec libvpx \
+ -crf 30 -threads 0 -bf 0 $@
+
+%_vp9.webm: %_ffv.mkv
+ $(FFMPEG) -i $< -vcodec libvpx-vp9 \
+ -crf 30 -threads 0 -bf 0 $@
+
+%_av1.mkv: %_ffv.mkv
+ $(FFMPEG) -i $< -vcodec libaom-av1 \
+ -crf 30 -threads 0 -bf 0 $@
+
+.PHONY: videos