<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello list,<br>
    <br>
    I'm using drawtext to burn-in the timestamp into a video.<br>
    the current way is to use<br>
    <br>
    <b>drawtext='fontfile=FreeSans.ttf:text=%{localtime\:%T  %d.%m.%Y}'</b><br>
    <br>
    but it only works fine with real-time encoding.<br>
    I'm receiving a UDP multicast stream and the problem is that the
    stream will be buffered, this leads into a slow down timestamp for
    the first 3-10 sec and after 10 sec it works fine.<br>
    <br>
    so take a look at<br>
    <b>drawtext='fontfile=FreeSans.ttf:text=%{pts\:localtime\:`date
      +%s`\:%T  %d.%m.%Y}'</b><br>
    <br>
    the date +%s will take the sec since 1970....<br>
    the problem is that it can take a few sec until the udp stream will
    probed and start to record. So the timestamp is always 3-10 sec in
    the past.<br>
    <br>
    So i think it would be a nice idea to define the offset with a
    special keyword like "now"<br>
    <br>
    <b>drawtext='fontfile=FreeSans.ttf:text=%{pts\:localtime\:now:%T 
      %d.%m.%Y}'</b><br>
    <br>
    now will calc the offset (in the code it is called delta) at the
    receiving of the first frame.<br>
    <br>
    for better understanding i have attached a small diff.<br>
    It is a little bit dirty because of the static int64 delta.<br>
    By the way the current impl works relay inefficient. It will parse
    always the same string for each frame.<br>
    So my example only parse the string if the delta is 0.<br>
    <br>
    This will also work fine with no real-time encoding.<br>
    What do you think, will this be a good enhancement??<br>
    <br>
    best regards <br>
    Patrick<br>
    <br>
    <br>
    <br>
    --- FFmpeg-release-3.0_orig/libavfilter/vf_drawtext.c   2016-09-05
    02:13:28.000000000 +0200<br>
    +++ FFmpeg-release-3.0/libavfilter/vf_drawtext.c 2016-09-22
    10:22:55.625648763 +0200<br>
    @@ -791,6 +791,7 @@<br>
         return 0;<br>
     }<br>
     <br>
    +static int64_t delta = 0;<br>
     static int func_pts(AVFilterContext *ctx, AVBPrint *bp,<br>
                         char *fct, unsigned argc, char **argv, int tag)<br>
     {<br>
    @@ -801,10 +802,13 @@<br>
     <br>
         fmt = argc >= 1 ? argv[0] : "flt";<br>
         if (argc >= 2) {<br>
    -        int64_t delta;<br>
    -        if ((ret = av_parse_time(&delta, argv[1], 1)) < 0) {<br>
    -            av_log(ctx, AV_LOG_ERROR, "Invalid delta '%s'\n",
    argv[1]);<br>
    -            return ret;<br>
    +        if (0 == delta) {<br>
    +            if (!strcmp(argv[1], "now")) {<br>
    +                delta = time(NULL)*1000000;<br>
    +            } else if ((ret = av_parse_time(&delta, argv[1],
    1)) < 0) {<br>
    +                av_log(ctx, AV_LOG_ERROR, "Invalid delta '%s'\n",
    argv[1]);<br>
    +                return ret;<br>
    +            } <br>
             }<br>
             pts += (double)delta / AV_TIME_BASE;<br>
         }<br>
    <div class="moz-signature"><br>
    </div>
  </body>
</html>