[FFmpeg-devel] [PATCH v2] lavfi/drawtext: Add localtime_ms for millisecond precision

"zhilizhao(赵志立)" quinkblack at foxmail.com
Fri Dec 10 04:47:56 EET 2021



> On Dec 10, 2021, at 3:11 AM, Thilo Borgmann <thilo.borgmann at mail.de> wrote:
> 
> Hi,
> 
> add %{localtime_ms}, %{gmtime_ms} functions to the drawtext filter. Same as %{localtime}/%{gmtime} but with additional millisecond part.
> 
> sorry for delay, second version including review remarks:
> 
> -get timing once
> -also add gmtime_ms instead of just localtime_ms
> 

> +    if (tag == 'M' || tag == 'm') {
> +        char ms[5] = {0};
> +        int64_t dnow = (unow - ((int64_t)now) * 1000000) / 1000;
> +        snprintf(ms, 5, ".%03d", (int)dnow);
> +        av_bprint_append_data(bp, ms, 4);
> +    }
> 


How about

    av_bprintf(&bp, ".%03d", (int)(unow % 1000000) / 1000);



More information about the ffmpeg-devel mailing list