Skip to content

Instantly share code, notes, and snippets.

@amake
Last active February 8, 2022 13:12
Show Gist options
  • Save amake/d2da4e45cf372a2850f6296bb8433860 to your computer and use it in GitHub Desktop.
Save amake/d2da4e45cf372a2850f6296bb8433860 to your computer and use it in GitHub Desktop.
Convert HEIC images to MP4 video
SHELL := /bin/bash
# Requires ffmpeg, libheif
heic := $(wildcard *.HEIC)
jpg := $(heic:.HEIC=.jpg)
.PHONY:
all: silent-pingpong.mp4 with-audio-pingpong.mp4
silent.mp4: $(jpg)
# ffmpeg video filter -vf
# - assumes vertical photos
# - resizes to iPhone XS max video resolution
ffmpeg -framerate 10 -pattern_type glob -i '*.jpg' -vf 'transpose=1,scale=1920:-1' $@
with-audio.mp4: silent.mp4 audio.m4a
ffmpeg -i $< -i $(word 2,$^) -c copy -map 0:v:0 -map 1:a:0 -shortest $@
%-pingpong.mp4: %.mp4 %-reversed.mp4
ffmpeg -f concat -safe 0 -i <(printf "file '%s'\n" $(addprefix $(PWD)/,$^)) -c copy $@
%.jpg: %.HEIC
heif-convert $< $@
%-reversed.mp4: %.mp4
ffmpeg -i $< -vf reverse -af areverse $@
.PHONY: clean
clean:
rm *.jpg *.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment