This guide provides instructions on how to concatenate multiple video files using FFmpeg, add a black screen between each video, and address common timestamp issues during the concatenation process.
- FFmpeg installed on your system.
- Videos to be concatenated should be in the same codec, resolution, and frame rate.
Ensure the black screen video matches the resolution and frame rate of your other videos.
ffmpeg -f lavfi -i color=c=black:s=1920x1080:r=30:d=1 black.mp4
Create a text file (filelist.txt
) listing all the video files to be concatenated, including the black screen video between each main video.
file 'VID_20240203_103925.mp4'
file 'black.mp4'
file 'VID_20240203_105117.mp4'
file 'black.mp4'
...
file 'VID_20240204_142836.mp4'
Use the following FFmpeg command to concatenate the videos without re-encoding:
ffmpeg -f concat -safe 0 -i filelist.txt -c copy output.mp4
If you encounter "Non-monotonic DTS" errors, use the following commands to fix the timestamps:
- Convert each video to MPEG-TS format:
ffmpeg -i input.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
- Concatenate TS files:
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts|...|intermediateN.ts" -c copy -bsf:a aac_adtstoasc output.mp4
To generate timestamps for YouTube chapters:
Calculate the start time for each video manually or using the script attached, accounting for the duration of each video and the 1-second black screens. Include these timestamps in your YouTube video description, formatted as follows:
00:00:00 Introduction
00:00:10 Chapter 1
00:05:15 Chapter 2
...
This method ensures that videos are concatenated with a uniform format, maintaining quality and ensuring proper playback without timestamp errors.