I would like to overlay a text and an image in a video. I know how to overlay text and an image. The problem is the text is not fixed, e.g “Sad, “Happy,” “Excited,” etc. I need to show an image right next to the text.
Is there a way to save the width of the text (text_w
) and use it in overlay for displaying image?
Something like
ffmpeg -i out.mp4 -i image.jpg -filter_complex \
"[0:v][1:v] overlay=(main_w-overlay_w)/2+text_w:(main_h-overlay_h)/2:enable='between(t,0,20)'" \
-pix_fmt yuv420p -c:a copy output.mp4
tw
,th
.