[FFmpeg-user] Optimal workflow for concatenating (reliably)

Jan Ehrhardt phpdev at ehrhardt.nl
Thu Apr 10 15:17:53 CEST 2014

hdn8 in gmane.comp.video.ffmpeg.user (Thu, 10 Apr 2014 04:54:41 -0700 (PDT)):
>I have a web application that for a user-given video file concatenates a
>short intro and outro, trims based on user-selected in and out points and
>overlays a watermark.

I am doing more or less the same. It is on Windows, but the same should be
possible on other OSs. It is in one pass:

ffmpeg.exe -i intro.mp4 -i main.mp4 -i outtro.mp4 \
	-filter_complex \
	"[0:v]setpts=PTS-STARTPTS[v0]; \
	[0:a]asetpts=PTS-STARTPTS,ebur128=metadata=1,volume=metadata=lavfi.r128.I[a0]; \
	[1:v]setpts=PTS-STARTPTS[v1]; \
	[1:a]asetpts=PTS-STARTPTS,ebur128=metadata=1,volume=metadata=lavfi.r128.I[a1]; \
	[2:v]setpts=PTS-STARTPTS[v2]; \
	[2:a]asetpts=PTS-STARTPTS,ebur128=metadata=1,volume=metadata=lavfi.r128.I[a2]; \
	[v0][a0][v1][a1][v2][a2]concat=n=3:v=1:a=1[v][a3];[a3]ebur128=metadata=1[a]" \
	-map [v] -map [a] -movflags +faststart \
	-s 384x288 -sws_flags bicubic -vcodec libx264 -b:v 320k -r 25 \
	-strict -2 -acodec libfaac -ab 96k -ar 48000 -ac 2 \
	-x264opts \

	-y join_process.mp4

The 'volume=metadata=lavfi.r128.I' is the audio normalizing part. You will
have to patch the FFmpeg sources for that:

I tried to convince the FFmpeg developers to add this to the FFmpeg core,
but got answers like "single-pass volume normalization is not possible."
and "using the intermediate value of r128.I or its equivalent from
volumedetect for volume normalization is WRONG.."

This was the original idea:

And this the sequential:

Reliable? Yes. Over 10000 videos have been concatenated/normalized by this


More information about the ffmpeg-user mailing list