Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
482ce0ce
Commit
482ce0ce
authored
Sep 18, 2011
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vf_drawtext: make x and y options parametric
Address trac issue #378.
parent
163854bc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
236 additions
and
21 deletions
+236
-21
filters.texi
doc/filters.texi
+93
-3
avfilter.h
libavfilter/avfilter.h
+1
-1
vf_drawtext.c
libavfilter/vf_drawtext.c
+142
-17
No files found.
doc/filters.texi
View file @
482ce0ce
...
@@ -738,10 +738,13 @@ parameter @var{text}.
...
@@ -738,10 +738,13 @@ parameter @var{text}.
If both text and textfile are specified, an error is thrown.
If both text and textfile are specified, an error is thrown.
@item x, y
@item x, y
The offsets where text will be drawn within the video frame.
The expressions which specify the offsets where text will be drawn
Relative to the top/left border of the output image.
within the video frame. They are relative to the top/left border of the
output image.
The default value of @var{x} and @var{y} is 0.
The default value of @var{x} and @var{y} is "0".
See below for the list of accepted constants.
@item fontsize
@item fontsize
The font size to be used for drawing text.
The font size to be used for drawing text.
...
@@ -809,6 +812,66 @@ The size in number of spaces to use for rendering the tab.
...
@@ -809,6 +812,66 @@ The size in number of spaces to use for rendering the tab.
Default value is 4.
Default value is 4.
@end table
@end table
The parameters for @var{x} and @var{y} are expressions containing the
following constants:
@table @option
@item E, PI, PHI
the corresponding mathematical approximated values for e
(euler number), pi (greek PI), PHI (golden ratio)
@item w, h
the input width and heigth
@item tw, text_w
the width of the rendered text
@item th, text_h
the height of the rendered text
@item lh, line_h
the height of each text line
@item sar
input sample aspect ratio
@item dar
input display aspect ratio, it is the same as (@var{w} / @var{h}) * @var{sar}
@item hsub, vsub
horizontal and vertical chroma subsample values. For example for the
pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
@item max_glyph_w
maximum glyph width, that is the maximum width for all the glyphs
contained in the rendered text
@item max_glyph_h
maximum glyph height, that is the maximum height for all the glyphs
contained in the rendered text, it is equivalent to @var{ascent} -
@var{descent}.
@item max_glyph_a, ascent
the maximum distance from the baseline to the highest/upper grid
coordinate used to place a glyph outline point, for all the rendered
glyphs.
It is a positive value, due to the grid's orientation with the Y axis
upwards.
@item max_glyph_d, descent
the maximum distance from the baseline to the lowest grid coordinate
used to place a glyph outline point, for all the rendered glyphs.
This is a negative value, due to the grid's orientation, with the Y axis
upwards.
@item n
the number of input frame, starting from 0
@item t
timestamp expressed in seconds, NAN if the input timestamp is unknown
@end table
Some examples follow.
Some examples follow.
@itemize
@itemize
...
@@ -835,6 +898,33 @@ drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test
...
@@ -835,6 +898,33 @@ drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='Test
Note that the double quotes are not necessary if spaces are not used
Note that the double quotes are not necessary if spaces are not used
within the parameter list.
within the parameter list.
@item
Show the text at the center of the video frame:
@example
drawtext=fontsize=30:fontfile=FreeSerif.ttf:text='hello world':x=(w-text_w)/2:y=(h-text_h-line_h)/2"
@end example
@item
Show a text line sliding from right to left in the last row of the video
frame. The file @file{LONG_LINE} is assumed to contain a single line
with no newlines.
@example
drawtext=fontsize=15:fontfile=FreeSerif.ttf:text=LONG_LINE:y=h-line_h:x=-50*t
@end example
@item
Show the content of file @file{CREDITS} off the bottom of the frame and scroll up.
@example
drawtext=fontsize=20:fontfile=FreeSerif.ttf:textfile=CREDITS:y=h-20*t"
@end example
@item
Draw a single green letter "g", at the center of the input video.
The glyph baseline is placed at half screen height.
@example
drawtext=fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_glyph_w)/2:y=h/2-ascent
@end example
@end itemize
@end itemize
For more information about libfreetype, check:
For more information about libfreetype, check:
...
...
libavfilter/avfilter.h
View file @
482ce0ce
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MINOR 43
#define LIBAVFILTER_VERSION_MINOR 43
#define LIBAVFILTER_VERSION_MICRO
4
#define LIBAVFILTER_VERSION_MICRO
5
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
LIBAVFILTER_VERSION_MINOR, \
...
...
libavfilter/vf_drawtext.c
View file @
482ce0ce
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment