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

houlei at uniontech.com houlei at uniontech.com
Fri Feb 19 10:43:09 EET 2021


From: Hou Lei <houlei at uniontech.com>

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

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





More information about the ffmpeg-devel mailing list