mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
lavfi: add drawvg video filter.
The drawvg filter can draw vector graphics on top of a video, using libcairo. It is enabled if FFmpeg is configured with `--enable-cairo`. The language for drawvg scripts is documented in `doc/drawvg-reference.texi`. There are two new tests: - `fate-filter-drawvg-interpreter` launch a script with most commands, and verify which libcairo functions are executed. - `fate-filter-drawvg-video` render a very simple image, just to verify that libcairo is working as expected. Signed-off-by: Ayose <ayosec@gmail.com>
This commit is contained in:
@@ -28,6 +28,7 @@ HTMLPAGES = $(AVPROGS-yes:%=doc/%.html) $(AVPROGS-yes:%=doc/%-all.html) $(COMP
|
||||
doc/mailing-list-faq.html \
|
||||
doc/nut.html \
|
||||
doc/platform.html \
|
||||
doc/drawvg-reference.html \
|
||||
$(SRC_PATH)/doc/bootstrap.min.css \
|
||||
$(SRC_PATH)/doc/style.min.css \
|
||||
$(SRC_PATH)/doc/default.css \
|
||||
|
||||
2772
doc/drawvg-reference.texi
Normal file
2772
doc/drawvg-reference.texi
Normal file
File diff suppressed because it is too large
Load Diff
@@ -13049,6 +13049,78 @@ For more information about libfribidi, check:
|
||||
For more information about libharfbuzz, check:
|
||||
@url{https://github.com/harfbuzz/harfbuzz}.
|
||||
|
||||
@anchor{drawvg}
|
||||
@section drawvg
|
||||
|
||||
Draw vector graphics on top of video frames, by executing a script written in
|
||||
a custom language called VGS (@emph{Vector Graphics Script}).
|
||||
|
||||
The documentation for the language can be found in
|
||||
@ref{,,drawvg - Language Reference,drawvg-reference}.
|
||||
|
||||
Graphics are rendered using the @uref{https://cairographics.org/,cario 2D
|
||||
graphics library}.
|
||||
|
||||
To enable compilation of this filter, you need to configure FFmpeg with
|
||||
@code{--enable-cairo}.
|
||||
|
||||
@subsection Parameters
|
||||
|
||||
Either @code{script} or @code{file} must be set.
|
||||
|
||||
@table @option
|
||||
|
||||
@item s, script
|
||||
Script source to draw the graphics.
|
||||
|
||||
@item file
|
||||
Path of the file to load the script source.
|
||||
|
||||
@end table
|
||||
|
||||
@subsection Pixel Formats
|
||||
|
||||
Since Cairo only supports RGB images, if the input video is something else (like
|
||||
YUV 4:2:0), before executing the script the video is converted to a format
|
||||
compatible with Cairo. Then, you have to use use either the @ref{format} filter,
|
||||
or the @code{-pix_fmt} option, to convert it to the expected format in the
|
||||
output.
|
||||
|
||||
@subsection Examples
|
||||
|
||||
@itemize
|
||||
@item
|
||||
Draw the outline of an ellipse.
|
||||
|
||||
@example
|
||||
ffmpeg -i input.webm \
|
||||
-vf 'drawvg=ellipse (w/2) (h/2) (w/3) (h/3) stroke' \
|
||||
-pix_fmt yuv420p \
|
||||
output.webm
|
||||
@end example
|
||||
|
||||
@item
|
||||
|
||||
Draw a square rotating in the middle of the frame.
|
||||
|
||||
The script for drawvg is in a file @code{draw.vgs}:
|
||||
|
||||
@example
|
||||
translate (w/2) (h/2)
|
||||
rotate t
|
||||
rect -100 -100 200 200
|
||||
setcolor red@@0.5
|
||||
fill
|
||||
@end example
|
||||
|
||||
Then:
|
||||
|
||||
@example
|
||||
ffmpeg -i input.webm -vf 'drawvg=file=draw.vgs,format=yuv420p' output.webm
|
||||
@end example
|
||||
|
||||
@end itemize
|
||||
|
||||
@section edgedetect
|
||||
|
||||
Detect and draw edges. The filter uses the Canny Edge Detection algorithm.
|
||||
|
||||
Reference in New Issue
Block a user