[FFmpeg-user] Recorded Frame Timestamps are Inconsistent! How to Fix it?

Hassan hassaniqbal931 at gmail.com
Mon Mar 15 19:43:38 EET 2021


Hello,

I am using ffmpeg on a Windows 10 machine and I want to record the desktop
at a high frame rate while appending accurate timestamps to each frame.
I am recording my desktop using the following command:

ffmpeg -f gdigrab -framerate 60 -i desktop -vf "settb=AVTB,
setpts='trunc(PTS/1K)*1K+st(1,trunc(RTCTIME/1K))-1K*trunc(ld(1)/1K)',
drawtext=fontfile=ArialBold.ttf:fontsize=40:fontcolor=white:text='%{localtime}.%{eif\:1M*t-1K*trunc(t*1K)\:d}:box=1:boxborderw=20:boxcolor=black at 1.0:x=10:y=10'"
-c:v libx264rgb -crf 0 -preset ultrafast output.mkv

The long text next to -vf flag is used to append timestamp (date and
current time in milliseconds) on the top left corner of the frame with
black background.

The issue is that, ideally, when I am recording at 60 FPS, each subsequent
frame should have a timestamp with an increment of 16.66 msec. However, the
timestamp is not incremented as such. Instead, it stays the same on a lot
of frames and then changes.

For example, when I break the video into frames, the frame titled
"img0428.png" has the timestamp 18:44:16.828 (hh:mm:ss.millisec)
[image: image.png].
Then until "next 40 frames, it says the same. On file "img0469.png", the
timestamp changes and becomes 18:44:17.510.
[image: image.png]
So, the timestamp changed after 41 frames and the time difference is 682
milliseconds. Ideally, each of the 40 frames between these two frames
should carry an incremental timestamp by a step size of 16.66 msec but this
is not happening.

Therefore, my questions are as follows:
1. Am I using the right method to append timestamps to the recorded frames?
2. What is the reason that the timestamping on the frames is not correct?
3. How can I fix this issue?
4. What are the alternate methods to append accurate epoch timestamps to
each of the recorded frames?

Please guide me. Thanks.

-- 
Regards
Hassan Iqbal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 17504 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20210315/3304d5b0/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 20986 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20210315/3304d5b0/attachment-0001.png>


More information about the ffmpeg-user mailing list