Concatenate video files
mouse 1870 · person cloud · link
Last update
2023-12-11
2023
12-11
«ffmpeg, mplayer/mencoder
join video files»

Use either of these commands to concatenate video files with the same codec and dimensions:

1
2
3
4
5
# mencoder
mencoder -oac copy -ovc copy -idx -o out.avi in*.avi

# ffmpeg
ls in*.avi | sed 's/.*/file \0/' | ffmpeg -f concat -c copy -i - out.avi

Check video resolutions:

1
2
3
4
5
6
for i in *.mp4; do
  echo -en "$i\t"
  ffprobe -v error -select_streams v:0 \
   -show_entries stream=width,height \
   -of csv=s=x:p=0 "$i"
done

To concatenate video files with different codecs and/or dimensions you have to reencode all files choosing common codecs/dimensions:

1
mencoder -oac mp3lame -ovc x264 -idx -vf expand=640:640 -o out.avi in*.avi

Source: FFmpeg / ffmpeg@stackoverflow, Mencoder