[FFmpeg-user] Using drawtext for date/time

Alex Agranovsky alex at sighthound.com
Fri Oct 9 00:12:23 CEST 2015

Moritz — thanks. Note, however, that I wanted to derive the text from pts (with optional application of some base time), rather than from the current time. Correct me if I’m wrong, but what you’ve described (localtime) can only do the latter.

I’ve just submitted a patch, which hopefully will introduce that functionality.


On October 8, 2015 at 4:26:24 PM, Moritz Barsnick (barsnick at gmx.net) wrote:

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

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:
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:

(Note: I haven't tried this.)

ffmpeg-user mailing list
ffmpeg-user at ffmpeg.org

More information about the ffmpeg-user mailing list