The videos I am trying to concatenate can have different technical metadata, like codec, resolution, etc. So I wrote a filtergraph that works for my purposes. My complete command can look like this:
ffmpeg -i "vid1.mp4" -i "vid2.mp4" -i "vid3.mp4" -filter_complex_script "filtergraph.txt" -map "[outv]" -map "[outa]" -c:v libx264 -r 60 -preset medium -crf 24 -c:a aac -b:a 160k "output.mp4"
And "filtergraph.txt" looks like this (autogenerated by my own script before). I have the filters to change all input resolutions to Full HD. (Newlines in the following snippet are just introduced for readability, they are not contained in my filtergraph.txt)
[0:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v0];
[1:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v1];
[2:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1[v2];
[v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[outv][outa]
Now in this case, it works, I have the three source videos, they can have different resolutions, codecs or even different framerates - they are all combinded into one Full HD 60 FPS output video.
The problem is, that I want to concatenate a large number of video files and get the error, that the command contains too many characters for cmd. That's why I already put the filtergraph to a seperate file and read it using -filter_complex_script
which works.
But it can still get too long if I have a few hundred source files that I want to concat.
As far as I tested it, I can't use -f concat -i listOfFiles.txt
because every source file would have to be in the same codec, resolution etc then, and I could not use the filtergraph for scaling due to the fact that ffmpeg would try to concat before demuxed output goes into filter.
So, how could I concat hundreds of videos while resizing them all to Full HD and applying the other filters, but keep the cmd line short?
Is there something similar to -filter_complex_script
but for input files? Or will I have to encode each source video to my desired target format first and then concat them with stream copy?