Commit bd8e7503 authored by Stefano Sabatini's avatar Stefano Sabatini Committed by Michael Niedermayer

Port drawtext filter by Hemanth from the libavfilter soc repo, with

the following additions:
* support to anti-aliased glyph rendering
* support to UTF-8 text and Unicode chars rendering
* support for RGB packed formats
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 704865fc
......@@ -169,6 +169,7 @@ External library support:
and libraw1394 [no]
--enable-libdirac enable Dirac support via libdirac [no]
--enable-libfaac enable FAAC support via libfaac [no]
--enable-libfreetype enable libfreetype [no]
--enable-libgsm enable GSM support via libgsm [no]
--enable-libmp3lame enable MP3 encoding via libmp3lame [no]
--enable-libnut enable NUT (de)muxing via libnut,
......@@ -897,6 +898,7 @@ CONFIG_LIST="
libdc1394
libdirac
libfaac
libfreetype
libgsm
libmp3lame
libnut
......@@ -1043,6 +1045,7 @@ HAVE_LIST="
llrintf
local_aligned_16
local_aligned_8
localtime_r
log2
log2f
loongson
......@@ -1425,6 +1428,7 @@ udp_protocol_deps="network"
# filters
blackframe_filter_deps="gpl"
cropdetect_filter_deps="gpl"
drawtext_filter_deps="libfreetype"
frei0r_filter_deps="frei0r dlopen strtok_r"
frei0r_src_filter_deps="frei0r dlopen strtok_r"
hqdn3d_filter_deps="gpl"
......@@ -2740,6 +2744,7 @@ check_func getrusage
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
check_func inet_aton $network_extralibs
check_func isatty
check_func localtime_r
check_func ${malloc_prefix}memalign && enable memalign
check_func mkstemp
check_func mmap
......@@ -2826,6 +2831,7 @@ enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
enabled libfreetype && add_cflags $(pkg-config --cflags freetype2) && require libfreetype ft2build.h FT_Init_FreeType -lfreetype
enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
......
......@@ -386,6 +386,118 @@ fade=in:0:25, fade=out:975:25
fade=in:5:20
@end example
@section drawtext
Draw text string or text from specified file on top of video using the
libfreetype library.
To enable compilation of this filter you need to configure FFmpeg with
@code{--enable-libfreetype}.
The filter also recognizes strftime() sequences in the provided text
and expands them accordingly. Check the documentation of strftime().
The filter accepts parameters as a list of @var{key}=@var{value} pairs,
separated by ":".
The description of the accepted parameters follows.
@table @option
@item fontfile
The font file to be used for drawing text. Path must be included.
This parameter is mandatory.
@item text
The text string to be drawn. The text must be a sequence of UTF-8
encoded characters.
This parameter is mandatory if no file is specified.
@item textfile
A text file containing text to be drawn. The text must be a sequence
of UTF-8 encoded characters
This parameter is mandatory if no text string is specified.
If both text and textfile are specified, an error is thrown.
@item x, y
The offsets where text will be drawn within the video frame.
Relative to the top/left border of the output image.
The default value of @var{x} and @var{y} is 0.
@item fontsize
The font size to be used for drawing text.
The default value of @var{size} is 16.
@item fontcolor
The color to be used for drawing fonts.
Either a string (e.g. "red") or in 0xRRGGBB[AA] format
(e.g. "0xff000033"), possibly followed by an alpha specifier.
The default value of @var{fontcolor} is "black".
@item boxcolor
The color to be used for drawing box around text.
Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
(e.g. "0xff00ff"), possibly followed by an alpha specifier.
The default value of @var{bgcolor} is "white".
@item box
Used to draw a box around text using background color.
Value should be either 1 (enable) or 0 (disable).
The default value of @var{box} is 0.
@item ft_load_flags
Flags to be used for loading the fonts.
The flags map the corresponding flags supported by libfreetype, and are
a combination of the following values:
@table @var
@item default
@item no_scale
@item no_hinting
@item render
@item no_bitmap
@item vertical_layout
@item force_autohint
@item crop_bitmap
@item pedantic
@item ignore_global_advance_width
@item no_recurse
@item ignore_transform
@item monochrome
@item linear_design
@item no_autohint
@item end table
@end table
Default value is "render".
For more information consult the documentation for the FT_LOAD_*
libfreetype flags.
@item tabsize
The size in number of spaces to use for rendering the tab.
Default value is 4.
@end table
For example the command:
@example
drawtext=fontfile=FreeSerif.ttf: text='Test Text': x=100: y=50: fontsize=24: fontcolor=yellow@@0.2: boxcolor=red@@0.2: box=1"
@end example
will draw 'Test Text' with font FreeSerif of size 24 at position
(100,50), text color is yellow, and draw a red box around text. Both
the text and the box have an opacity of 20%.
Note that the double quotes are not necessary if spaces are not used
within the parameter list.
For more information about libfreetype, check:
@url{http://www.freetype.org/}
@section fifo
Buffer input images and send them when they are requested.
......
......@@ -27,6 +27,7 @@ OBJS-$(CONFIG_COPY_FILTER) += vf_copy.o
OBJS-$(CONFIG_CROP_FILTER) += vf_crop.o
OBJS-$(CONFIG_CROPDETECT_FILTER) += vf_cropdetect.o
OBJS-$(CONFIG_DRAWBOX_FILTER) += vf_drawbox.o
OBJS-$(CONFIG_DRAWTEXT_FILTER) += vf_drawtext.o
OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o
OBJS-$(CONFIG_FIFO_FILTER) += vf_fifo.o
OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o
......
......@@ -45,6 +45,7 @@ void avfilter_register_all(void)
REGISTER_FILTER (CROP, crop, vf);
REGISTER_FILTER (CROPDETECT, cropdetect, vf);
REGISTER_FILTER (DRAWBOX, drawbox, vf);
REGISTER_FILTER (DRAWTEXT, drawtext, vf);
REGISTER_FILTER (FADE, fade, vf);
REGISTER_FILTER (FIFO, fifo, vf);
REGISTER_FILTER (FORMAT, format, vf);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment