[FFmpeg-user] filter_complex: concat an image to a video, but ALSO xfade
Arif Driessen
arifd86 at gmail.com
Wed Sep 22 20:34:07 EEST 2021
Hi guys,
What I have:
[0:0] = thumbnail.png
[1:0] = aevalsrc="-2+random(0)" (white noise)
[2:0][2:1] = IN_VIDEO.avi (mono audio track)
What I want:
- [0:0] and [1:0] to play/loop unmodified for
${FADE_IN_DURATION_SECONDS}
- THEN [0:0] will xfade into [2:0]
- (however this is achieved, [2:1] must stay in sync with [2:0])
This is what I have:
ffmpeg \
-loop 1 -framerate ${FPS} -t ${FADE_IN_DURATION_SECONDS} -i ${THUMBNAIL}
`# [file 0]` \
-t ${FADE_IN_DURATION_SECONDS} -f lavfi -i aevalsrc="-2+random(0)" `#
white noise track` `# [file 1]` \
-ss ${TRIM_START_SECONDS} \
-i ${IN_VIDEO} `# [file 2]` \
-to ${TRIM_END_SECONDS} \
-filter_complex \
"
`# match thumbnail to IN_VIDEO specs`
[0:0]
scale=${VIDEO_RESOLUTION}
[scaled];
[scaled]
format=pix_fmts=${PIXEL_FORMAT}
[formatted];
[formatted]
setsar=${DAR}
[sar_matched];
[sar_matched]
settb=expr=${TIME_BASE}
[thumbnail];
`# make a copy for later concat`
[thumbnail]
split
[thumbnail_a][thumbnail_b];
`# xfade thumbnail with video`
[thumbnail_a][2:0]
xfade=
transition=fade
[xfaded];
`# concat thumbnail with xfaded`
[thumbnail_b][1:0][xfaded][2:1]
concat=n=2:v=1:a=1
" \
-vcodec libx264 \
-preset veryfast \
-crf 18 \
-pix_fmt yuv420p \
-acodec aac \
-b:a 192k \
${OUT_VIDEO}
--
If I don't do the concating, the xfading works fine. Once I split and
concat, then the concating works perfectly, but I've lost the xfade.
Any ideas?
Many thanks,
Arif Driessen
More information about the ffmpeg-user
mailing list