Combine multiple filter_complex and overlay functions with FFMpeg Commands

Viewed 40

I am having trouble combining these 4 passes in ffmpeg into a single process.

First

exec("$this->ffmpeg -i ".storage_path('/app/public_html/uploads/job.mp4')." -codec:a libmp3lame -b:a 128k -vf scale=".$res_dimension->res_width."x".$res_dimension->res_height.",setsar=1:1 ".storage_path('2.mp4'));

Second

exec("$this->ffmpeg -i ".storage_path($original_file_path)."  -codec:a libmp3lame -b:a 128k -vf scale=".$res_dimension->res_width."x".$res_dimension->res_height.",setsar=1:1 ".storage_path('3.mp4'));

Third

exec("$this->ffmpeg -i ".storage_path('3.mp4')."  -i ".storage_path('/app/public_html/uploads/images/index2.png')."  -filter_complex 'overlay=20:20' ".storage_path('4.mp4'));

Forth

exec("$this->ffmpeg -i ".storage_path('2.mp4')."  -i  ".storage_path('3.mp4')." -filter_complex '[0:v]  [0:a]  [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]' -map '[v]' -map '[a]' ".storage_path('out4.mp4'));
1 Answers

Your undefined variables make it difficult to understand what you want. The ffmpeg commands as actually being executed would have been easier to follow. But as far as I can tell you want to do something like this:

ffmpeg -i input0.mp4 -i input1.mp4 -i image.png -filter_complex "[0:v]scale=1280:720,setsar=1[v0];[1:v]scale=1280:720,setsar=1[bg];[bg][2]overlay=20:20[v1];[v0][0:a][v1][1:a]concat=n=2:v=1:a=1" output.mp4
Related