Concatenate Videos with Different Sample Rates in FFmpeg

To concatenate two videos with different audio sample rates in FFmpeg, you cannot use the basic “demuxer” concat method, as it requires identical stream properties. Instead, you must re-encode the files using FFmpeg’s filter_complex tool. This process resamples the audio tracks to a matching frequency (such as 48,000 Hz) and standardizes the video streams before merging them into a single, seamless output file.

The FFmpeg Command

If your video dimensions match but the audio sample rates differ, use the following command to resample the audio to 48 kHz (48000 Hz) and concatenate the files:

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex \
"[0:a]aresample=48000[a0]; \
 [1:a]aresample=48000[a1]; \
 [0:v][a0][1:v][a1]concat=n=2:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" output.mp4

How the Command Works

Handling Different Resolutions and Sample Rates

If your videos also have different resolutions or aspect ratios in addition to different sample rates, you must scale the video streams alongside resampling the audio to prevent playback errors. Use this expanded command:

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex \
"[0:v]scale=1920:1080,setsar=1[v0]; \
 [0:a]aresample=48000[a0]; \
 [1:v]scale=1920:1080,setsar=1[v1]; \
 [1:a]aresample=48000[a1]; \
 [v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" output.mp4

This version forces both video streams to a standard 1080p resolution (1920:1080) and sets a 1:1 Sample Aspect Ratio (setsar=1), guaranteeing a smooth transition between the two clips.