FFMPEG - concatenation of a dynamic number of files with different codecs

Viewed 102

I am trying to write a bash-script for FFMPEG that concatenates a dynamic number of video-files with different codecs.

This is what i have right now: The script basically does the job and concatenates 3 videos.

ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 \
    -filter_complex "[0:v] [0:a] [1:v] [1:a] [2:v] [2:a] concat=n=3:v=1:a=1 [v] [a]" \
    -map "[v]" -map "[a]" out.mp4

But as mentioned i would like to write a script which can process a dynamic number of video-files.

For this purpose i have created a text file that contains all the source-material.

file './lib/intro.mp4'
file './temp/1.mp4'
file './temp/2.mp4'
file './temp/3.mp4'
file './lib/outro.mp4'

I know that i can easily pass a text-file to the -i parameter. The problem is that it the -filter_complex-parameter is not dynamic. The number of files is fixed here.

ffmpeg -i files.txt \
    -filter_complex "[0:v] [0:a] [1:v] [1:a] [2:v] [2:a] concat=n=3:v=1:a=1 [v] [a]" \ 
    -map "[v]" -map "[a]" out.mp4

Is it possible to modify the script to concatenate a dynamic amount of video-files?

Thanks in advance!

0 Answers
Related