DEV Community

Discussion on: Concatenate Videos Together Using ffmpeg!

dak425 profile image
Donald Feury Author • Edited on

You could definitely script it, just loop over each file in the directory where your videos are stored and run the same command

Could look something like this:

#! /usr/bin/env sh


for f in $dir/*.mp4
    ffmpeg -i $intro -i $f -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" "$out/$(basename $f)"
Enter fullscreen mode Exit fullscreen mode

I just whipped that up real fast and not sure if it works 100% but the idea is that it will:

  • Loop over all the files with .mp4 file extensions in the given directory
  • Run an ffmpeg command that use as inputs, the file given as the argument for the intro and the file of the current iteration of the loop, and write the newly combined version to a given directory
andr_dessent_18eee53f6af profile image
André Dessent

Thanks for your quick answer! sorry buy i'm a beginner with programming and ffmpeg and this programm would make me win a lot of time! i have a question concerning concatenation:
i have two files
1-video1 is an intro: mp4 file, 1280x720, 25 fps, with only one stream (only video, no audio)
2-video2: mp4 file, 1920x1080, 25 fps
i would like to change video2 resolution to 1280x720, and then concatenate video1 and the new video2.
is there a way to do that in one command?