diff mbox series

[FFmpeg-devel] When using ffmpeg to record screen, set the operating system time and set the system time backward. Stop screen recording, unable to save video.

Message ID 20210219084309.31037-1-houlei@uniontech.com
State New
Headers show
Series [FFmpeg-devel] When using ffmpeg to record screen, set the operating system time and set the system time backward. Stop screen recording, unable to save video.
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

houlei@uniontech.com Feb. 19, 2021, 8:43 a.m. UTC
From: Hou Lei <houlei@uniontech.com>

Signed-off-by: Hou Lei <houlei@uniontech.com>
---
 libavdevice/xcbgrab.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Nicolas George Feb. 19, 2021, 9:47 a.m. UTC | #1
houlei@uniontech.com (12021-02-19):
> From: Hou Lei <houlei@uniontech.com>
> 
> Signed-off-by: Hou Lei <houlei@uniontech.com>
> ---
>  libavdevice/xcbgrab.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)

NAK. The correct fix is to use the monotonic clock for syncing. And make
it an option to use it for frame timestamps too.

Regards,
Marton Balint Feb. 19, 2021, 8:39 p.m. UTC | #2
On Fri, 19 Feb 2021, Nicolas George wrote:

> houlei@uniontech.com (12021-02-19):
>> From: Hou Lei <houlei@uniontech.com>
>>
>> Signed-off-by: Hou Lei <houlei@uniontech.com>
>> ---
>>  libavdevice/xcbgrab.c | 11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> NAK. The correct fix is to use the monotonic clock for syncing.

I just sent a patch for this exactly.

Regards,
Marton

> And make
> it an option to use it for frame timestamps too.
>
> Regards,
>
> --
>  Nicolas George
>
diff mbox series

Patch

diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index be5d5ea2cf..7e886064fe 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -208,7 +208,16 @@  static int64_t wait_frame(AVFormatContext *s, AVPacket *pkt)
     for (;;) {
         curtime = av_gettime();
         delay   = c->time_frame - curtime;
-        if (delay <= 0)
+
+        //When the user changes the operating system time, can synchronization be forced here?
+        /*
+        if (delay > 10) {
+           c->time_frame = curtime + c->frame_duration;
+           break;
+        }
+        */
+        //When the user changes the operating system time, add timeout judgment.
+        if (delay <= 0 || delay > 10)
             break;
         av_usleep(delay);
     }