[FFmpeg-user] Using drawtext for date/time

Moritz Barsnick barsnick at gmx.net
Thu Oct 8 22:19:39 CEST 2015


Hi Alex,

On Thu, Oct 08, 2015 at 15:11:46 -0400, Alex Agranovsky wrote:

> I’d like to burn a date/time using drawtext, based on PTS with the
> addition of a specified basetime. Looking at the code,
> expansion=strftime seems to do exactly what I want — but it is marked
> as deprecated. Alternatives don’t seem to cut it: func_pts  doesn’t
> print date and does not take basetime into account, func_strftime
> doesn’t take basetime into account, and uses current time rather than
> PTS. What is the reason the strftime expansion had been deprecated?
> Is there a current equivalent?

I think you only need to read a bit further down in the filter's
documentation:

  If ‘expansion’ is set to normal (which is the default), the following
  expansion mechanism is used.
  [...]
  Sequence [sic] of the form %{...} are expanded. The text between the
  braces is a function name, possibly followed by arguments separated
  by ':'.
  [...]
  The following functions are available:
  [...]
  localtime
    The time at which the filter is running, expressed in the local
    time zone. It can accept an argument: a strftime() format string.

So, this boils down to:
  -vf 'drawtext=expansion=%{localtime:%H\:%M\:%S}'
or something like this with a lot more escaping. :-)
Warning: escape hell:
https://trac.ffmpeg.org/ticket/3253

(Note: I haven't tried this.)

Moritz


More information about the ffmpeg-user mailing list