Last active
December 26, 2020 06:11
-
-
Save scateu/3f9a16675d90045fe4e65506d6aaaee1 to your computer and use it in GitHub Desktop.
This file contains 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
CUTTER = python3 jumpcutter/jumpcutter.py | |
%_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 | |
clean: | |
if [ -d ./TEMP ]; then rm -r ./TEMP; fi | |
prepare: | |
git clone https://github.com/petermg/jumpcutter | |
cd jumpcutter; pip3 install -r requirements.txt;pip3 install pytube3 opencv-python | |
# HOWTO: | |
# 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 |
This file contains 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
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 $@ | |
clean: | |
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