I try to create a command that will add the intro to the start of an arbitrary video file. But that file can have arbitrary size, aspect ratio, even pixel format.
So I need to resize intro and add pads if necessary before concatenation, then concatenate intro and the file, then convert with right codec and pixel format (using -codec
and -pix_fmt
for this).
I suppose that the video file can be absolutely any dimension and aspect ratio: wide, square, even vertical. So I need to fit the intro into the target dimension by adding paddings.
There is what I use:
ffmpeg -i intro.mp4 -i video.mp4 -filter_complex \
"[0][1]scale2ref=iw:ih:force_original_aspect_ratio=decrease[intro][main], \
[intro]pad=ow:oh:(ow-iw)/2:(oh-ih)/2[0:v]; [0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[v][a]" \
-map '[v]' -map '[a]' -sws_flags spline -vcodec libx264 -movflags +faststart \
-r 25 -g 50 -crf 18 -me_method umh -pix_fmt yuv420p -trellis 0 -bf 8 -acodec aac
-strict -2 -ar 44100 -ab 128k -f mp4 out.mp4 -y
But still can't figure out...
Now there is the error:
Filter scale2ref:ref has an unconnected output
FFmpeg version:
ffmpeg version git-2019-10-19-31aafda Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20191010
Thank you!