Commit Graph

228 Commits

Author SHA1 Message Date
Nicolas George 670051b524 lavfi/drawtext: ignore final LF of textfile.
A standard text file ends with a final LF.
Without this change, it is interpreted as an empty final line,
and visible with the box option.
The current behavior can be achieved by actually having
an empty line at the end of the file.

Fix trac ticket #7948.
2021-02-17 11:53:51 +01:00
Rosen Penev 8beb9e571c avfilter/vf_drawtext: only test available exceptions
soft float systems do not define these macros under musl.

Fixes: Ticket7102

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-09 00:59:21 +02:00
Paul B Mahol d64cbd4fda remove CHAR_MIN/CHAR_MAX usage
It is not needed at all.
2020-03-17 22:46:36 +01:00
Marton Balint 62d92a878d avfilter/vf_drawtext: do not overread text if the last UTF8 sequence is invalid
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-31 00:15:13 +01:00
Marton Balint 5ac8389cfa avfilter/vf_drawtext: use replacement chars for invalid UTF8 sequences
continue is explicitly disallowed for GET_UTF8, so let's fix that as well.
Fixes crash with invalid UTF8 sequences.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-31 00:15:13 +01:00
Gyan Doshi 287620f59c avfilter/drawtext: log why input pad failed to be configured 2019-12-24 11:04:52 +05:30
Calvin Walton 2bd21b9609 vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
Changes to vf_drawtext.c written by
Calvin Walton <calvin.walton@kepstin.ca>

Changes to filters.texi written by
greg Luce <electron.rotoscope@gmail.com>
with lots of help from Moritz Barsnick and Gyan

Fixes #7947.
2019-07-07 11:12:07 +05:30
Gyan Doshi 8cf947ca4c avfilter/drawtext: stop resource leak
Fixes Coverity CID 1445099
2019-05-16 10:30:28 +05:30
Gyan Doshi 87db1ca632 avfilter/drawtext: make command processing error-resilient
Prevents crash or interruption in text rendering
if new option string contains invalid values.
2019-05-13 10:34:32 +05:30
Gyan Doshi 1a31c2b5df avfilter/drawtext: fix box sizing
At present, box size is clipped to frame size before being drawn,
which can lead to the box not fully covering animated text which is
longer than one or both frame dimensions.

Since ff_blend_rectangle correctly takes care of clipping, it is skipped
here which results in correct box sizing
2018-07-13 10:11:15 +05:30
Vishwanath Dixit 37abfe8c2d avfilter/drawtext: present 'hms' formatted 'pts' in 24h format
HMS is formatted as HH:MM:SS.mmm, but, HH part is not limited to
24 hours. For example, the the drawn text may look like this:
243029:20:30.342. To present the timestamp in more readable and
user friendly format, this patch provides an additional option
to limit the hour part in the range 0-23.

Note: Actually the above required format can be obtained with
format options 'localtime' and 'gmtime', but,  milliseconds part
is not supported in those formats.
2018-06-04 10:57:45 +05:30
Steven Liu 27fe8930e0 avfilter: add comments for duplicate line
comment about the looks like a duplicate line.
but that is used to reason x is expressed from y

Suggested-by: Paul B Mahol
Suggested-by: Michael Niedermayer
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2018-02-01 10:55:19 +08:00
Gyan Doshi 6c1c6c6c71 avfilter/drawtext - implement fix_bounds
When enabled, text, including effects like shadow or box, will be
completely bound within the video frame.

Default value changed to false to keep continuity of behaviour.

Fixes #6960.

Signed-off-by: Kyle Swanson <k@ylo.ph>
2018-01-20 16:30:56 -08:00
Muhammad Faiz 6af050d7d0 avfilter: do not use AVFrame accessor
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
2017-04-23 14:40:30 +07:00
Brett Harrison 6442e4ab3c avfilter/vf_drawtext: added expr evaluation to drawtext fontsize
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-04-19 12:39:05 +02:00
Clément Bœsch ca6f0f85bb Merge commit '85baef4ff1512bcc2544928bfa5f42072903a691'
* commit '85baef4ff1512bcc2544928bfa5f42072903a691':
  vf_drawtext: Move static keyword to beginning of variable declaration

This commit is mostly a noop, see:
d9e2aceb7f
6d7aa437e1

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-29 14:26:57 +02:00
Kieran Kunhya 4cca2f74f2 vf_drawtext: Fix memory leak 2017-03-21 12:15:50 +00:00
Steven Liu 90096e42e1 avfilter:vf_drawtext: add new line space size set parameter
add line_spacing parameter to set the space between two lines

Based on an idea by: Leandro Santiago <leandrosansilva@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2017-01-19 07:09:22 +08:00
Nicolas George 183ce55b0d lavfi: split frame_count between input and output.
AVFilterLink.frame_count is supposed to count the number of frames
that were passed on the link, but with min_samples, that number is
not always the same for the source and destination filters.
With the addition of a FIFO on the link, the difference will become
more significant.

Split the variable in two: frame_count_in counts the number of
frames that entered the link, frame_count_out counts the number
of frames that were sent to the destination filter.
2016-11-13 10:41:16 +01:00
Alex Agranovsky 88db6c2890 avfilter/vf_drawtext: fixed default/flt formatting ignoring offset parameter
Signed-off-by: Alex Agranovsky <alex@sighthound.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-11-06 23:02:38 +01:00
Diego Biurrun 85baef4ff1 vf_drawtext: Move static keyword to beginning of variable declaration
libavfilter/vf_drawtext.c:226:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration]
2016-11-02 10:29:00 +01:00
Paul B Mahol 9d16e46d9e avfilter/drawutils: allow drawing opaque text on transparent background
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-09-21 11:54:00 +02:00
Michael Niedermayer 2e67a99fbc avfilter/vf_drawtext: Check return code of load_glyph()
Fixes segfault
Fixes Ticket5347

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-24 12:39:25 +02:00
Tobias Rapp ee104580c5 avfilter/vf_drawtext: add optional default value to metadata function
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2016-04-13 08:39:07 +02:00
Carl Eugen Hoyos ae9f2e6f28 lavfi/drawtext: Fix microsecond display.
Fixes ticket #4792.
2016-01-03 22:55:31 +01:00
Ganesh Ajjanagadde ff1442a51d lavfi/vf_drawtext: replace round by llrint
llrint is at least as fast, and avoids an implicit cast.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 08:18:12 -08:00
Clément Bœsch d3dbae1c71 lavfi/drawtext: fix shadow[xy] descriptions 2015-12-21 16:42:14 +01:00
Clément Bœsch 1d6308dbc6 lavfi/drawtext: hide first font load warning when fontconfig is present 2015-12-21 16:07:22 +01:00
Clément Bœsch 4cb26c3c35 lavfi/drawtext: fix crash when no text, file or timecode provided 2015-12-21 15:54:20 +01:00
Ganesh Ajjanagadde 7c8fcbbde3 avutil/tree: add additional const qualifier to the comparator
libc's qsort comparator has a const qualifier on both arguments. This
adds a missing const qualifier to exactly match the comparator API.

Existing usages of av_tree_find, av_tree_insert are appropriately
modified: type signature changes of the comparators, and removal of
unnecessary void * casts of function pointers.

Reviewed-by: Henrik Gramner <henrik@gramner.com>
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-24 20:38:07 -04:00
Ganesh Ajjanagadde 4c96985af1 all: remove some casts of function pointer to void *
These casts are unnecessary, and may safely be removed.
Found by enabling -Wpedantic on clang 3.7.

Tested with FATE.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-24 15:14:59 -04:00
Alex Agranovsky cf28490e56 avfilter/drawtext: allow to format pts with strftime
Signed-off-by: Alex Agranovsky <alex@sighthound.com>
2015-10-12 16:56:58 +02:00
Clément Bœsch 1cab6a33cd avfilter/drawtext: use AV_OPT_TYPE_BOOL for a few options 2015-09-08 23:56:43 +02:00
Luca Barbato 98c9ade985 drawtext: Move the strftime expansion in a separate function
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-08-02 15:18:48 +02:00
Luca Barbato fe026ba960 drawtext: Drop stray guards
There is a fallback for localtime_r and it is in use already.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-08-02 15:14:33 +02:00
Michael Niedermayer 122150168f Merge commit '9b2c57bef5e2f3f61a5fd708ba7d5351f5b3f386'
* commit '9b2c57bef5e2f3f61a5fd708ba7d5351f5b3f386':
  drawtext: Add an alpha option

Conflicts:
	doc/filters.texi
	libavfilter/vf_drawtext.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-21 20:20:58 +02:00
Luca Barbato 9b2c57bef5 drawtext: Add an alpha option
And document both `draw` and `alpha`.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-04-21 11:13:30 +02:00
Vittorio Giovara 1a3eb042c7 Replace av_dlog with normal av_log at trace level
This applies to every library where performance is not critical.
2015-04-19 12:41:59 +01:00
Ivan Efimov 2051b401cc avfilter/drawtext: fix frame mem leak
Signed-off-by: Ivan Efimov <ioefimov@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-14 12:04:52 +02:00
Paul B Mahol a0854c084e avfilter: handle error in query_formats() in bunch of filters
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-04-08 13:05:06 +00:00
Marton Balint c84b75c89c vf_drawtext: add support for setting box border width
Signed-off-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-31 13:41:25 +02:00
Michael Niedermayer ee7b5d4ef8 avfilter/vf_drawtext: Change enums to int, which are accessed via AVOption as int
This fixes depending on implementation defined behavior
2015-03-08 21:10:31 +01:00
Михаил Муковников 71f29410e7 lavfi: Increase drawtext font size limits
Raise the maximum font size to a larger value.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-12-07 13:15:03 +01:00
Michael Niedermayer 013c3eb05c avfilter/vf_drawtext: use gm_time_r() for thread saftey
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-02 19:20:26 +01:00
Michael Niedermayer 4360c6ff61 Merge commit '6b9b42cc5576e1819ad1e29d98940066fd14b2d6'
* commit '6b9b42cc5576e1819ad1e29d98940066fd14b2d6':
  drawtext: Remove the ifdef for localtime_r

Conflicts:
	libavfilter/vf_drawtext.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-26 03:12:37 +01:00
Martin Storsjö 6b9b42cc55 drawtext: Remove the ifdef for localtime_r
If it isn't available in the system, we've got a fallback to
the normal localtime function, so normal code can assume it is
available as long as time_internal.h is included.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-26 00:14:54 +03:00
Michael Niedermayer 0b2f860db5 Merge commit 'f401792595dd7760f531e8a3bd2336e9033bd45a'
* commit 'f401792595dd7760f531e8a3bd2336e9033bd45a':
  vf_drawtext: Do not leak the mmapped textfile

Conflicts:
	libavfilter/vf_drawtext.c

See: 6956b048d8
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-18 21:33:04 +02:00
Luca Barbato f401792595 vf_drawtext: Do not leak the mmapped textfile
And validate its size while at it.

CC: libav-stable@libav.org
Bug-Id: CID 1244189
2014-10-18 16:15:09 +01:00
James Almer 59d8050df1 avfilter: remove obsolete FF_API_DRAWTEXT_OLD_TIMELINE cruft 2014-10-12 15:54:58 -03:00
Karl Kiniger 903156aa8a vf_drawtext: add missing clear of pointers after av_expr_free()
Fixes segfault when using sendcmd with drawtext.

Since LIBAVFILTER_VERSION_MAJOR 5 FF_API_DRAWTEXT_OLD_TIMELINE
evaluates to 0.

Signed-off-by: Karl Kiniger <karl.kiniger@med.ge.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-11 23:16:31 +02:00