Skip to content

Instantly share code, notes, and snippets.

@asquared
Created December 9, 2014 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asquared/9f23a30bb497b132f355 to your computer and use it in GitHub Desktop.
Save asquared/9f23a30bb497b132f355 to your computer and use it in GitHub Desktop.
FFMPEG=/home/armena/ffmpeg/ffmpeg
ARCHIVE=/mnt/video1-volume1/Archive
# List of all the encodes we want for a production.
%.all: %-400.mp4 %-800.mp4 %-1200.mp4 %-2000.mp4 %-2800.mp4 %-3200.mp4 %-4400.mp4
echo "encode done!"
# create files that point to the original source file, this works around
# make's inability to create implicit rules for multiple file types
%.in: $(ARCHIVE)/%.mxf
echo "$<" > "$@"
%.in: $(ARCHIVE)/%.mov
echo "$<" > "$@"
%.in: $(ARCHIVE)/%.avi
echo "$<" > "$@"
%.in: $(ARCHIVE)/%.mpg
echo "$<" > "$@"
%.in: $(ARCHIVE)/%.mp4
echo "$<" > "$@"
# Rule for first pass encode.
%-pass1: %.in
$(FFMPEG) -y -i `cat $<` -vf yadif -f mp4 -vcodec libx264 \
-s 1920x1080 -b:v 4400k \
-pix_fmt yuv420p \
-preset medium -aspect 16:9 -pass 1 \
-passlogfile `basename $<` \
-an /dev/null
touch $@
# Rules for various pass-2 encodes.
%-400.mp4: %.in %-pass1
$(FFMPEG) -y -i `cat $<` -vf yadif -f mp4 -vcodec libx264 \
-s 480x270 -b:v 400k \
-pix_fmt yuv420p \
-preset medium -aspect 16:9 -pass 2 \
-x264opts no-mbtree \
-strict experimental -acodec aac -b:a 64k -ar 22050 \
-passlogfile `basename $<` \
$@
%-800.mp4: %.in %-pass1
$(FFMPEG) -y -i `cat $<` -vf yadif -f mp4 -vcodec libx264 \
-s 640x360 -b:v 800k \
-pix_fmt yuv420p \
-preset medium -aspect 16:9 -pass 2 \
-x264opts no-mbtree \
-strict experimental -acodec aac -b:a 128k -ar 48000 \
-passlogfile `basename $<` \
$@
%-1200.mp4: %.in %-pass1
$(FFMPEG) -y -i `cat $<` -vf yadif -f mp4 -vcodec libx264 \
-s 640x360 -b:v 1200k \
-pix_fmt yuv420p \
-preset medium -aspect 16:9 -pass 2 \
-x264opts no-mbtree \
-strict experimental -acodec aac -b:a 128k -ar 48000 \
-passlogfile `basename $<` \
$@
%-2000.mp4: %.in %-pass1
$(FFMPEG) -y -i `cat $<` -vf yadif -f mp4 -vcodec libx264 \
-s 960x540 -b:v 2000k \
-pix_fmt yuv420p \
-preset medium -aspect 16:9 -pass 2 \
-x264opts no-mbtree \
-strict experimental -acodec aac -b:a 192k -ar 48000 \
-passlogfile `basename $<` \
$@
%-2800.mp4: %.in %-pass1
$(FFMPEG) -y -i `cat $<` -vf yadif -f mp4 -vcodec libx264 \
-s 960x540 -b:v 2800k \
-pix_fmt yuv420p \
-preset medium -aspect 16:9 -pass 2 \
-x264opts no-mbtree \
-strict experimental -acodec aac -b:a 192k -ar 48000 \
-passlogfile `basename $<` \
$@
%-3200.mp4: %.in %-pass1
$(FFMPEG) -y -i `cat $<` -vf yadif -f mp4 -vcodec libx264 \
-s 1280x720 -b:v 3200k \
-pix_fmt yuv420p \
-preset medium -aspect 16:9 -pass 2 \
-x264opts no-mbtree \
-strict experimental -acodec aac -b:a 256k -ar 48000 \
-passlogfile `basename $<` \
$@
%-4400.mp4: %.in %-pass1
$(FFMPEG) -y -i `cat $<` -vf yadif -f mp4 -vcodec libx264 \
-s 1920x1080 -b:v 4400k \
-pix_fmt yuv420p \
-preset medium -aspect 16:9 -pass 2 \
-x264opts no-mbtree \
-strict experimental -acodec aac -b:a 256k -ar 48000 \
-passlogfile `basename $<` \
$@
# Since the mp4 files we want are technically intermediate files, we list
# them out here so make doesn't go and delete them when it's done.
.PRECIOUS: %-400.mp4 %-800.mp4 %-1200.mp4 %-2000.mp4 %-2800.mp4 %-3200.mp4 %-4400.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment