Last active
February 22, 2025 08:09
-
-
Save showa-yojyo/da8569814f71628491f10b6b6019d2f7 to your computer and use it in GitHub Desktop.
図書館逃避行用 Makefile RC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Makefile for 図書館逃避行 | |
# Variables supplied from the command line or another Makefile, by `make -f | |
# Makefile.another`. | |
TITLE ?= 東京都ダミー区ダミー図書館 | |
OUTPUT ?= ./a.mp4 | |
INKSCAPE ?= inkscape | |
FFMPEG ?= ffmpeg | |
CONCAT_TOOL ?= video-concat-xfade | |
OVERLAY_STYLE ?= softlight | |
# You must explicitly set this variable: | |
SVG_TEMPLATE ?= /path/to/video-title-template.svg | |
SHELL := /bin/bash | |
# TODO: overridable or internal? | |
BUILDDIR := ./build | |
SRCDIR := ./src | |
# Internal variables | |
concat-audio := $(BUILDDIR)/audio-only.m4a | |
concat-video := $(BUILDDIR)/video-only.mp4 | |
command-audio := $(BUILDDIR)/audio-command.sh | |
command-video := $(BUILDDIR)/video-command.sh | |
image := $(BUILDDIR)/title.png | |
svg := $(SRCDIR)/video-title.svg | |
objects := $(concat-audio) $(concat-video) $(command-audio) $(command-video) $(image) | |
source-videos != ls -v $(SRCDIR)/*.mp4 | |
.PHONY: help all clean test image svg audio video commands | |
help: | |
@echo "Usage:" | |
@echo " make image TITLE=<title> to make the title image file" | |
@echo " make all TITLE=<title> OUTPUT=<path> to build all" | |
clean: | |
-rm -f $(objects) | |
# E.g. make image TITLE=東京都渋谷区こもれび大和田図書館 | |
# or | |
# make image -- if build/svg file exists | |
image: $(image) | |
$(image): $(svg) | |
@mkdir -p $(@D) | |
@$(INKSCAPE) --export-type=png --export-filename=$@ $< | |
# E.g. make svg TITLE=東京都渋谷区こもれび大和田図書館 | |
svg: $(svg) | |
$(svg): | |
@mkdir -p $(@D) | |
@cp $(SVG_TEMPLATE) $(svg) | |
@sed -i "s/東京都なんとか図書館/$(TITLE)/" $@ | |
# E.g. make svg TITLE=東京都渋谷区こもれび大和田図書館 OUTPUT=../shibuya-komorebi.mp4 | |
all: $(OUTPUT) | |
$(OUTPUT): $(concat-audio) $(concat-video) | |
$(FFMPEG) -y -i $(concat-video) -i $(concat-audio) \ | |
-c:v copy -c:a aac -map 0:v:0 -map 1:a:0 -movflags +faststart $@ | |
# video-concat-xfade is a path | |
commands: $(command-audio) $(command-video) | |
$(command-audio) $(command-video)&: $(source-videos) $(image) | |
$(CONCAT_TOOL) \ | |
--concat-audio-path $(concat-audio) \ | |
--concat-video-path $(concat-video) \ | |
--command-audio-path $(command-audio) \ | |
--command-video-path $(command-video) \ | |
--overlay-image-path $(image) \ | |
--overlay-style $(OVERLAY_STYLE) \ | |
$(source-videos) | |
audio: $(concat-audio) | |
$(concat-audio): $(command-audio) | |
$$SHELL $(command-audio) | |
video: $(concat-video) | |
$(concat-video): $(command-video) $(image) | |
$$SHELL $(command-video) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment