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: fontcolor=black@0.7: box=1: boxcolor=red@0.2" -t 20 output.mp4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.