Search code examples
bashshellvideoffmpegiterm

How to use ffmpeg merge all the videos in the catalog in an orderly manner?


I have a lot of regular video clips 1.mp4 2.mp4 ... 11.mp4

I use command below to combine all the clips:
ffmpeg -f concat -safe 0 -i <(for f in ./*.mp4; do echo "file '$PWD/$f'"; done) -c copy -pix_fmt yuv420p -r 30 all.mp4

But the sequence will be disordered, For example, the file #1 is not file #2, but file #11。

how can I correctly merge according to the number size sequence?


Solution

  • add sort -V as below:

    ffmpeg -f concat -safe 0 -i <(for f in ./*.webm; do echo "file '$PWD/$f'"; done | sort -V) -c copy -pix_fmt yuv420p -r 30 output.webm