Last active
May 24, 2019 14:29
-
-
Save vo/0de97fbd88ee1c7c5d51c6b807c81b00 to your computer and use it in GitHub Desktop.
Makefile to fix broken mp4 files
This file contains hidden or 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
# This makefile finds all .mp4 files and attempts to repair their indexes without re-encoding. | |
# It's a makefile so you can use "make -jN" to take advantage of N cores on your computer finish many quickly | |
MP4:=$(wildcard *.mp4) | |
OUTDIR:=out | |
FAST:=$(patsubst %.mp4,${OUTDIR}/%.fast.mp4,${MP4}) | |
REKEYED:=$(patsubst %.mp4,${OUTDIR}/%.rekeyed.mp4,${MP4}) | |
all: | |
@echo "Use 'make fast' to do a fast file index rebuild" | |
@echo "Use 'make rekeyed' to fix broken or missing frames" | |
fast: ${FAST} | |
rekeyed: ${REKEYED} | |
# create output directory | |
outdir: | |
mkdir -p ${OUTDIR} | |
# how to create fixed files | |
${OUTDIR}/%.fast.mp4: %.mp4 outdir | |
ffmpeg -i $< -c copy $@ | |
# how to create rekeyed files | |
${OUTDIR}/%.rekeyed.mp4: %.mp4 outdir | |
ffmpeg -i $< -force_key_frames "expr:gte(t,n_forced*3)" $@ | |
clean: | |
rm -rf ${FAST} ${REKEYED} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment