summaryrefslogtreecommitdiff
path: root/video.mk
blob: 0c01b337496256ec9bcfbd1c66b4c97c537a23b0 (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
CLEAN_TARGETS      += clean_video
REAL_CLEAN_TARGETS += real_clean_video

## Video encoder options
# with added voice low-pass filter and frame rate reduced to 15 (good for slides)
ffmpegOptions ?= -movflags faststart -r 15 -c:v libx264 -preset veryfast -tune stillimage -c:a libfdk_aac -vbr 1 -cutoff 4000
# remove audio track and recode video (good for slides)
#ffmpegOptions ?= -movflags faststart -r 15 -c:v libx264 -preset veryfast -tune stillimage -an
# remove audio track and recode video (do not change frame rate)
# ffmpegOptions ?= -movflags faststart -c:v libx264 -preset veryfast -tune stillimage -an
# recode video with no filters
# ffmpegOptions ?= -movflags faststart -c:v libx264 -preset veryfast -tune stillimage -c:a libfdk_aac -vbr 1

rawDir ?= rawVideo
recodedDir ?= recodedVideo
readyDir ?= readyVideo
video_ext_in ?= mp4
video_ext_out ?= mp4

dest_dir_video_recoded ?= $(dest_dir)/$(recodedDir)
dest_dir_video_ready ?= $(dest_dir)/$(readyDir)
destination_dirs += $(dest_dir_video_recoded) $(dest_dir_video_ready)

rawVideo = $(wildcard $(rawDir)/*.$(video_ext_in))
recoded_video_from_raw = $(rawVideo:$(rawDir)/%.$(video_ext_in)=$(recodedDir)/%.$(video_ext_out))
recoded_video_dest_targets = $(rawVideo:$(rawDir)/%.$(video_ext_in)=$(dest_dir_video_recoded)/%.$(video_ext_out))

readyVideo = $(wildcard $(readyDir)/*.$(video_ext_out))
ready_video_dest_targets = $(readyVideo:$(readyDir)/%=$(dest_dir_video_ready)/%)


recoded_video: $(recoded_video_from_raw)

$(dest_dir_video_ready):
	$(INSTALL) -d -m 0755 '$@'

$(dest_dir_video_recoded):
	$(INSTALL) -d -m 0755 '$@'

$(recodedDir):
	$(INSTALL) -d -m 0755 '$@'

$(recodedDir)/%.$(video_ext_out) : $(rawDir)/%.$(video_ext_in) | $(recodedDir)
	ffmpeg -i $< $(ffmpegOptions) $@

install_recoded_video: $(recoded_video_dest_targets)
install_ready_video: $(ready_video_dest_targets)

# $(dest_dir_video_recoded): 
	# $(INSTALL) -d -m 0755 '$@'

$(recoded_video_dest_targets): $(dest_dir_video_recoded)/% : $(recodedDir)/% | $(dest_dir_video_recoded)
ifneq ($(strip $(recoded_video_from_raw)),)
	$(INSTALL) -m 0644 '$<' '$@'
endif

$(ready_video_dest_targets): $(dest_dir_video_ready)/% : $(readyDir)/% | $(dest_dir_video_ready)
ifneq ($(strip $(readyVideo)),)
	$(INSTALL) -m 0644 '$<' '$@'
endif

clean_video:

real_clean_video:
ifneq ($(strip $(recoded_video_from_raw)),)
	rm -f $(recoded_video_from_raw)
endif