Skip to content

Instantly share code, notes, and snippets.

@samelie
Created October 3, 2015 16:33
Show Gist options
  • Save samelie/dbf10bb80e2fda7ed648 to your computer and use it in GitHub Desktop.
Save samelie/dbf10bb80e2fda7ed648 to your computer and use it in GitHub Desktop.
ffmpeg command
encode blur timeline , 0->10sec
ffmpeg -i vid2.mp4 -vf "boxblur=20:enable='between(t,0,10)'" -y testtest.mp4
//complete
ffmpeg -i vid2.mp4 -vf "boxblur=20:enable='between(t,0,10)'" -y -c:v libx264 -c:a libfdk_aac -movflags +faststart -pix_fmt yuv420p -keyint_min 6 -profile:v high -level 4.2 -maxrate 3000k testtest.mp4
@samelie
Copy link
Author

samelie commented Oct 19, 2015

fade in and out
crossfade images:

ffmpeg
-loop 1 -t 3 -i 0.png
-loop 1 -t 3 -i 1.png
-loop 1 -t 3 -i 2.png
-loop 1 -t 3 -i 3.png
-loop 1 -t 3 -i 4.png
-filter_complex
"[0:v]trim=duration=2,fade=t=in:st=0:d=0.5[fade0];
[1:v][0:v]blend=all_expr='A_(if(gte(T,3.0),1,T/3.0))+B_(1-(if(gte(T,3.0),1,T/3.0)))'[b1v];
[2:v][1:v]blend=all_expr='A_(if(gte(T,3.0),1,T/3.0))+B_(1-(if(gte(T,3.0),1,T/3.0)))'[b2v];
[3:v][2:v]blend=all_expr='A_(if(gte(T,3.0),1,T/3.0))+B_(1-(if(gte(T,3.0),1,T/3.0)))'[b3v];
[4:v][3:v]blend=all_expr='A_(if(gte(T,3.0),1,T/3.0))+B_(1-(if(gte(T,3.0),1,T/3.0)))'[b4v];
[4:v]trim=duration=2,fade=t=out:st=0:d=0.5[fade1];
[fade0][0:v][b1v][1:v][b2v][2:v][b3v][3:v][b4v][4:v][fade1]concat=n=11:v=1:a=0,format=yuv420p[v]" -map "[v]" -y out3.mp4

@samelie
Copy link
Author

samelie commented Oct 21, 2015

SAR/DAR mismatch on image inputs
//******************
ERROR:
[Parsed_blend_3 @ 0x7fef00e03a00] First input link top parameters (size 1280x720, SAR 72:72) do not match the corresponding second input link bottom parameters (1280x720, SAR 1:1)
//*******************
Fixed by doing setsar
Removing scale
https://ffmpeg.org/pipermail/ffmpeg-user/2012-August/009125.html

In the case of images. This wasnt resolved this way. Had to make a ffmpeg convert first.
var cmd = 'ffmpeg -i ' + out + ' -vf scale=' + W + ":" + H + ',setsar=1/1,setdar=16/9 -f image2 ' + out2;

@samelie
Copy link
Author

samelie commented Oct 21, 2015

FILTER GRAPHS
ffmpeg -loop 1 -t 3 -i -loop 1 -t 3 -i -filter_complex "[0:v]scale=1280:720,setsar=1/1[vid0];
[1:v]scale=1280:720,setsar=1/1[vid1];
[vid0]trim=duration=0,fade=t=in:st=0:d=1.5[fade0];
[vid1][fade0]blend=all_expr='A_(if(gte(T,1.5),1,T/1.5))+B_(1-(if(gte(T,1.5),1,T/1.5)))'[b0v];
[b0v]=n=1:v=1:a=0,setsar=1:1,format=yuv420p[v]" -map "[v]" -g 25 -y -c:v libx264 -movflags +faststart -profile:v high -level 4.1 -maxrate 3000k

Notice how you pass the graphs along...

@samelie
Copy link
Author

samelie commented Jan 4, 2016

for i in *.mov; do ffmpeg -i $i -y -c:v libx264 -c:a libfdk_aac -movflags +faststart -pix_fmt yuv420p -profile:v high -level 4.1 -crf 24 $i.mp4; done

@samelie
Copy link
Author

samelie commented Jan 11, 2016

for i in *.mov; do ffmpeg -i $i -y -c:v libx264 -c:a libfdk_aac -movflags +faststart -pix_fmt yuv420p -profile:v high -level 4.1 -vf scale=-1:720 -crf 21 $i.mp4; done

@samelie
Copy link
Author

samelie commented Feb 17, 2016

LETTER BOX PRESERVE ASPECT RATIO NO CROP

Define video size

width=1280;
height=720;

/usr/local/bin/ffmpeg -framerate 1 -pattern_type glob -i "$1"/'_.jpg' -c:v libx264 -filter:v "scale=iw_min($width/iw,$height/ih):ih_min($width/iw,$height/ih), pad=$width:$height:($width-iw_min($width/iw,$height/ih))/2:($height-ih*min($width/iw,$height/ih))/2" out.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment