Created
August 17, 2020 19:59
-
-
Save mitchsmith/4b116ce611037c34f69a5192b97359a1 to your computer and use it in GitHub Desktop.
Deep dive into the ffmpeg man page
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
#!/usr/bin/env bash | |
IMGDIR=/home/john/Projects/video_projects/notd/assets/images/intro/ | |
VIDDIR=/home/john/Projects/video_projects/notd/assets/video/ | |
TMPDIR=tmp/ | |
OUTPUTDIR=../tmp/ | |
#ls $IMGDIR | |
mkdir $TMPDIR | |
# create init sequence from pngs --> step0 | |
ffmpeg -r 6 -f image2 -s 1920x1080 -i ${IMGDIR}notd_init/%03d.png -vcodec libx264 -crf 5 -pix_fmt yuv420p ${TMPDIR}step0.mp4 && | |
# set framerate for init sequence to 25 --> step1 | |
ffmpeg -i ${TMPDIR}step0.mp4 -filter:v fps=fps=25 ${TMPDIR}step1.mp4 && | |
# create six seconds of white @ 25fps --> step 2 | |
ffmpeg -f lavfi -i [email protected]:s=hd1080:duration=6:rate=25 ${TMPDIR}step2.mp4 && | |
# create large teaparty for panning across empty bg --> step3 | |
ffmpeg -loop 1 -i ${IMGDIR}Tea_Party.png -c:v libx264 -t 6 -pix_fmt yuv420p -vf scale=3840:2160 ${TMPDIR}step3.mp4 && | |
# pan step3 result across blank bg from left to right --> step4 | |
ffmpeg -f lavfi -i [email protected]:s=hd1080:duration=6:rate=25 -i ${TMPDIR}step3.mp4 -filter_complex "[0][1]overlay=x='if(lte(-w/2+(t)*800,-500),-w/2+(t)*800,-500)':y=-650[out]" -map [out] -y ${TMPDIR}step4.mp4 && | |
# create large occupy for panning across empty bg --step5 | |
ffmpeg -loop 1 -i ${IMGDIR}occupyws.png -c:v libx264 -t 6 -pix_fmt yuv420p -vf scale=3840:2160 ${TMPDIR}step5.mp4 && | |
# pan step5 result across blank bg from right to left -- step6 | |
ffmpeg -f lavfi -i [email protected]:s=hd1080:duration=6:rate=25 -i ${TMPDIR}step5.mp4 -filter_complex "[0][1]overlay=x='if(gte(w/3-(t)*800,0),-(t)*800,-w/3)':y=-400[out]" -map [out] -y ${TMPDIR}step6.mp4 && | |
# fade step4 result (teaparty slide) into blank bg from step2 result --> step7 | |
ffmpeg -i ${TMPDIR}step2.mp4 -i ${TMPDIR}step4.mp4 -filter_complex "[1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+0/TB[over];[0:v][over]overlay=format=yuv420[outv]" -vcodec libx264 -map [outv] ${TMPDIR}step7.mp4 && | |
# crosfade step7 result with step6 result --> step8 | |
ffmpeg -i ${TMPDIR}step7.mp4 -i ${TMPDIR}step6.mp4 -f lavfi -i color=black:s=hd1080 -filter_complex "[0:v]format=pix_fmts=yuva420p,fade=t=out:st=3:d=1:alpha=1,setpts=PTS-STARTPTS[va0];[1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+3/TB[va1];[2:v]scale=1920x1080,trim=duration=9[over];[over][va0]overlay[over1];[over1][va1]overlay=format=yuv420[outv]" -vcodec libx264 -map [outv] ${TMPDIR}step8.mp4 && | |
# create from 2016 map --> step9 | |
ffmpeg -loop 1 -i ${IMGDIR}map2016.png -c:v libx264 -t 4 -pix_fmt yuv420p ${TMPDIR}step9.mp4 && | |
# slide step9 result (2016 map) down from top over step8 result at second 6 --> step10 | |
ffmpeg -i ${TMPDIR}step8.mp4 -i ${TMPDIR}step9.mp4 -filter_complex "[1]setpts=PTS-STARTPTS+5/TB[over];[0][over]overlay=x=0:y='if(lte(-h+(t-5)^4*600,0),-h+(t-5)^4*600,0)'[out]" -map [out] ${TMPDIR}step10.mp4 && | |
# create zoomout from JH Covid-19 Map --> step11 | |
ffmpeg -framerate 25 -loop 1 -i ${IMGDIR}covid19_jh_map_test.png -filter_complex "[0:v]zoompan=z='if(lte(zoom,1.0),4.5,max(1.001,zoom-0.05))':x='iw/3-(iw/zoom/3)':y='ih/4-(ih/zoom/4)':d=250,scale=1920x1080,trim=duration=5[v]" -map "[v]" -y ${TMPDIR}step11.mp4 && | |
# crosfade step10 result with step11 result --> step12 | |
ffmpeg -i ${TMPDIR}step10.mp4 -i ${TMPDIR}step11.mp4 -f lavfi -i color=black:s=hd1080 -filter_complex "[0:v]format=pix_fmts=yuva420p,fade=t=out:st=7:d=1:alpha=1,setpts=PTS-STARTPTS[va0];[1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+7/TB[va1];[2:v]scale=1920x1080,trim=duration=11[over];[over][va0]overlay[over1];[over1][va1]overlay=format=yuv420[outv]" -vcodec libx264 -map [outv] ${TMPDIR}step12.mp4 && | |
# slide trump over step12 result --> step13 | |
ffmpeg -i ${TMPDIR}step12.mp4 -i ${VIDDIR}trumpeaster.mp4 -filter_complex "[1:v]split[a][b];[a]crop=iw:ih/2:0:0,setpts=PTS+10/TB[top]; [b]crop=iw:ih/2:0:ih/2,setpts=PTS+10/TB[bottom]; [0:v][top]overlay=enable='between(t,10,13)':x='if(lte(-w+(t-10)*1000,0),-w+(t-10)*1000,0)':y=0[tmp]; [tmp][bottom]overlay=enable='between(t,10,13)':x='if(gte(w-(t-10)*1000,0),w-(t-10)*1000,0)':y=h,trim=duration=13[out]" -map [out] -y ${TMPDIR}step13.mp4 && | |
# concatenate step1 result (init sequence) with step13 result (teaparty fadein) --> step14 | |
echo file \'${TMPDIR}step1.mp4\' >> inputs.txt && | |
echo file \'${TMPDIR}step13.mp4\' >> inputs.txt && | |
ffmpeg -f concat -i inputs.txt -c copy ${OUTPUTDIR}step14.mp4 && | |
rm inputs.txt && | |
rm -rf ${TMPDIR} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment