[FFmpeg-devel] [PATCH] libavutil/timestamp.h: Fix loss of precision in timestamps for silencedetect on long files

Marton Balint cus at passwd.hu
Thu Feb 22 11:16:07 EET 2024



On Thu, 22 Feb 2024, Allan Cady via ffmpeg-devel wrote:

> I had a similar thought, as all timestamps would have the same issue.
>
> This is my first contribution here, and I don't know the code very well, 
> so I was being cautious. I'm open to expanding the scope, but I'm sure I 
> would need some help doing it right and not breaking things.
>
> For starters, I'm curious why there are two functions & macros:
>
> av_ts2str/av_ts_make_string (which used "%" format specifier)

That takes a 64-bit integer timestamp and is actually using "%"PRId64 
because that is the correct (portable) format string for an int64_t 
variable.

> av_ts2timestr/av_ts_make_time_string (which used "%6g")

That takes an integer timestamp and a rational time base. Float timestamps 
(in seconds) is calculated by multiplying the two, that is what is 
printed.

>
> Do you know the rationale for that? I see that only av_ts2timestr is used in silencedetect.c.
>
> And are you suggesting we should fold those two functions into one?

No, they have different purpose. The first prints out a timestamps which 
can be in any time base. The second prints out a timestamp in seconds.

>
> I did notice something in the output from silencedetect. After I made my 
> change, I see the output is now:
>
>
> frame:92404 pts:53224175 pts_time:2413.79
> lavfi.silence_start=2411.120272
> frame:92411 pts:53228207 pts_time:2413.98
> lavfi.silence_end=2413.992744
> lavfi.silence_duration=2.872472
>
>
> I see that the pts_time values still have the original formatting. I 
> don't know what pts_time is, or where those lines are coming from. Seems 
> like maybe those should have fixed precision as well.

Well, that is likely using the same function, but you only fixed 
silencedetect, right?

>
> Guidance for a noob please? Thanks.
>
> (P.S. Can you tell me, when I reply to the list (as opposed to patch 
> submission using git send-email), how should I address the email? 
> Obviously it should go to ffmpeg-devel at ffmpeg.org, but should I include 
> you as a recipient, or as a cc:, or only to the list? or is there some 
> other way it gets directed to you? Any other guidance on how to format 
> email? Thanks.)

I don't think there is a rule, I have seen it happen both with or without 
CC. You don't need to CC me though, as I am a regular on the list, but 
others may have other preference.

Regards,
Marton

PS: Please avoid top positing in you replies.


More information about the ffmpeg-devel mailing list