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

Thilo Borgmann thilo.borgmann at mail.de
Fri Dec 10 13:36:21 EET 2021



On 10 Dec 2021, at 3:47, zhilizhao(赵志立) wrote:

>> 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);

Makes way too much sense. I need holidays…

Attached v3.

Thanks!
-Thilo
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: v3-0001-lavfi-drawtext-Add-localtime_ms-for-millisecond-p.patch
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211210/57d525a9/attachment.ksh>


More information about the ffmpeg-devel mailing list