[FFmpeg-user] Generating an rgb24 pix_fmt solid color using lavfi by default

Kuban Altan kuban.altan at sinefekt.com
Wed Oct 29 19:07:39 CET 2014


I try to generate user avatars, using the initials of a user. Here is the
code:

*ffmpeg -v debug -f lavfi -i "color=c=0x0044DD:s=80x80" -vf
"format=pix_fmts=rgb24,drawtext=fontfile=/windows/fonts/arial.ttf:fontsize=40:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:text='KA'"
-vframes 1 -y ka_thumb.png*

Is working fine. But I have one minor problem. The resulting text is
rendered into a rgb24 buffer, and seems fine. But the problem is, the color
I create as *0x0044DD* is in *yuv420p* pixel format by default. What I am
doing as a workaround, first generating a colored buffer in yuv420 pixel
format, then convert it to *rgb24*, then render text over that color in
rgb24 mode. The pixel format conversion step in between seems to be
unneeded. How can I avoid this conversion step, and directly create a
colored background in *rgb24 *pixel format using *lavfi*?




*[lavfi @ 0000000002a9f680] All info foundInput #0, lavfi, from
'color=c=0x0044DD:s=80x80':  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0, 1, 1/25: Video: rawvideo (I420 / 0x30323449), yuv420p, 80x80
[SAR 1:1 DAR 1:1], 1/25, 25 tbr, 25 tbn, 25 tbc*

Looking at debug info, I can see that Stream #0:0 is originally yuv420p

kuban altan


More information about the ffmpeg-user mailing list