Friday, May 3, 2024
19
rated 0 times [  19] [ 0]  / answers: 1 / hits: 7953  / 2 Years ago, tue, july 12, 2022, 1:22:16

I need to paint an image with text in the center via command-line to further put into the video. A simple yellow text on black background.



I tried FFmpeg way:



ffmpeg -loop 1 -r 1 -i b.png -b:v 1M -vf "scale=320:240, drawtext=fontfile=/usr/share/fonts/truetype/DejaVuSans.ttf: text='Test Text'" -vcodec mpeg4 -acodec aac preroll.mp4


Which gave me the following error:



[AVFilterGraph @ 0xf56020] No such filter: 'drawtext'


I tried to install ivtools and tried drawtool and idraw which are obviously for desktop environments.



How to create a simple image with text in Ubuntu programatically?


More From » command-line

 Answers
6

What about this command:



convert -background black -size 800x480 -fill "#ff0080"  -pointsize 72 -gravity center label:'Ask Ubuntu' output.png


enter image description here



By using above command you create an empty .png image which its background color is black.



-background color

   set the background color.

   the default background color (if none is specified or found in the image) is white.



The created image size will be 800x480(width[xheight]).



-size width[xheight][+offset]

   set the width and height of the raw image.



-fill color

   color to use when filling a graphic primitive.



This option accepts a color name, a hex color, or a numerical RGB, RGBA, HSL, HSLA, CMYK, or CMYKA specification. See Color Names for a description of how to properly specify the color argument.



For example,



 -fill blue
-fill "#ff0080"
-fill "rgb(255,0,128)"


Enclose the color specification in quotation marks to prevent the "#" or the parentheses from being interpreted by your shell.



To print a complete list of color names, use the -list color option.



-pointsize size

   pointsize of the PostScript, OPTION1, or TrueType font.



-gravity type

   sets the current gravity suggestion for various other settings and options.



Choices include: NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast. Use -list gravity to get a complete list of -gravity settings available in your ImageMagick installation.



label:'your Text Here' write your text into image.png.



Also see more examples.



See full command-line options


[#22410] Wednesday, July 13, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
truwom

Total Points: 101
Total Questions: 99
Total Answers: 100

Location: Ivory Coast
Member since Tue, Sep 15, 2020
4 Years ago
;