[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 \

global_header=1:partitions=p8x8+b8x8+i8x8:level_idc=30:cabac=0:subq=3:qp_min=0:qp_max=51:qp_step=4:me=dia:subme=0:mixed_refs=0:me_range=16:chroma_me=1:trellis=0:8x8dct=0:cqm=flat:chroma_qp_offset=0:nr=0:keyint=25:min_keyint=12:scenecut=0:ratetol=1.0:qcomp=0.60:ip_factor=1.4:weightp=0:fast_pskip=1:frameref=1:bframes=0:mbtree=1:rc_lookahead=15:sliced_threads=0:threads=8\
	-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:
https://github.com/Jan-E/MyMpeg/blob/master/ffmpeg_patches/volnorm_new.patch

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:
http://comments.gmane.org/gmane.comp.video.ffmpeg.devel/159589

And this the sequential:
http://comments.gmane.org/gmane.comp.video.ffmpeg.devel/166113

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

Jan



More information about the ffmpeg-user mailing list