Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
CUTTER = python3 jumpcutter/
%_0.3.mp4: %.mkv
ffmpeg -i $< -c:v copy $(basename $<).mp4
if [ -d ./TEMP ]; then rm -r ./TEMP; fi
${CUTTER} --silent_threshold 0.3 --input_file $(basename $<).mp4 --output_file $(basename $<)_0.3.mp4
%_wechat.mp4: %_0.3.mp4
ffmpeg -i $< -c copy -t 00:05:00.00 $@
%_0.1.mp4 %_0.2.mp4 %_0.3.mp4: %.mp4
if [ -d ./TEMP ]; then rm -r ./TEMP; fi
${CUTTER} --silent_threshold $(lastword $(subst _, ,$(basename $@))) --input_file $< --output_file $@
.PHONY: clean prepare
if [ -d ./TEMP ]; then rm -r ./TEMP; fi
git clone
cd jumpcutter; pip3 install -r requirements.txt;pip3 install pytube3 opencv-python
# 1. Save all to Makefile
# 2. $ make prepare
# 3. Suppose you get a foo.mp4
# 4. $ make foo_0.3.mp4
# OR $ make foo_0.2.mp4
# OR $ make foo_0.1.mp4
# OR $ make foo_0.1.mp4 foo_0.2.mp4
OBJS = $(wildcard *.mp4)
TARGETS = $(OBJS:.mp4=.trimmed.mp4)
trim: ${TARGETS}
all: ${TARGETS}
printf "${foreach t,$(TARGETS),$(addsuffix \n,$t)}" | perl -ne 'print "file $$_"' | ffmpeg -protocol_whitelist file,pipe -f concat -i - -c copy joined.mp4
%.trimmed.mp4: %.mp4
ffmpeg -i $< -c copy -ss 00:00:10.00 $@
rm *.trimmed.mp4
.PHONEY: clean all trim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment