summaryrefslogtreecommitdiff
path: root/Makefile
blob: 5b0b99d015f8185b70ce8fabcf61af3b2c7d88c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
FFMPEG ?= ffmpeg
FFMPEG += -v warning $(FFMPEGFLAGS)
OPUSENC ?= opusenc
ZOPFLIPNG ?= zopflipng
JPEGOPTIM ?= jpegoptim
CWEBP ?= cwebp

DUMP ?= www/dump

all: video audio images

# === VIDEO ===

VIDEO := $(wildcard $(DUMP)/video/*.mkv)
MP4 := $(patsubst %.mkv,%.mp4,$(VIDEO))
WEBM := $(patsubst %.mkv,%.webm,$(VIDEO))
OGV := $(patsubst %.mkv,%.ogv,$(VIDEO))
CVIDEO := $(MP4) $(WEBM) $(OGV)

video: $(CVIDEO)

%.mp4: %.mkv
	$(FFMPEG) -i $< -c:v libx264 -preset slower -tune animation -c:a libfdk_aac $@

%.webm: %.mkv
	$(FFMPEG) -i $< -c:v libvpx -crf 15 -b:v 1M -c:a copy $@

%.ogv: %.mkv
	$(FFMPEG) -i $< -c:v libtheora -qscale:v 6 -c:a copy $@

# === AUDIO ===

AUDIO := $(shell find $(DUMP)/bgm $(DUMP)/sfx -name '*.ogg')
OPUS := $(patsubst %.ogg,%.opus,$(AUDIO))
M4A := $(patsubst %.ogg,%.m4a,$(AUDIO))
CAUDIO := $(OPUS) $(M4A)

audio: $(CAUDIO)

%.wav: %.ogg
	$(FFMPEG) -i $< -c:a pcm_s16le $@

%.opus: %.wav
	$(OPUSENC) --bitrate 64 $< $@

%.m4a: %.wav
	$(FFMPEG) -i $< -c:a libfdk_aac -vbr 2 $@

# === IMAGES ===

PNG := $(shell find $(DUMP) -name '*.png')
JPG := $(shell find $(DUMP) -name '*.jpg')
WEBP := $(patsubst %.png,%.webp,$(PNG)) \
        $(patsubst %.jpg,%.webp,$(JPG))

images: $(WEBP)

%.webp: %.png
	$(ZOPFLIPNG) -m -y $< $<
	$(CWEBP) -q 99 -m 6 $< -o $@

%.webp: %.jpg
	$(JPEGOPTIM) --strip-all $<
	$(CWEBP) -q 90 -m 6 $< -o $@

clean:
	rm $(CVIDEO) $(CAUDIO) $(WEBP)

.PHONY: video audio images clean