1

I am making a video from single image using ffmpeg and draw text on top of the video.

How can I drawtext that will overlay on top of the scaled video size instead of the image scale?

Right now when I add a text, the X and Y begin from the top left corner of the image, not the scaled video itself. The image has smaller dimensions than video scale, so I need to drawtext regardless of image size. If the text goes outside of image scale, it gets cut off, although the unfilled black border of the remaining scaled video is still there.

This is the command I am using.

ffmpeg -loop 1 -r 1 -i image.jpg -b:v 1M -vf "scale=320:240, drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: text='Test Text': x=200: y=100: fontsize=30: [email protected]: box=1: [email protected]" -t 20 output.mp4

2 Answers 2

0

If the image is the only video source then video is just the image and "overlay from the top left corner of the video" means the same as "overlay from the top left corner of the image". So you are doing it correctly.

The black border that you mention is not part of the video. It is inserted by some media players when opening very narrow videos because the media player controls panel is wider than than the video. For example VLC media player has rather wide controls/menu bar and it pads the video with big borders. But Windows Media Player does not display any black border as its controls fit in the 320p video width.

0

Got it working with below command:

ffmpeg -loop 1 -i image.jpg -r 29.970 -c:v libx264 -t 15 -pix_fmt yuv420p -profile:v high -level 4.2 -vf "scale=1920:1080, drawtext = text='Resumes in %{eif\:15-t\:d}': x=200: y=100: fontsize=30: [email protected]: box=1: [email protected]" out.mp4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .