[FFmpeg-devel] av_read_frame timeout

gga ggarra13 at gmail.com
Sun Nov 17 23:37:58 EET 2019


The following patch adds a timeout interrupt to av_read_frame to prevent 
it from hanging up the application.  This patch was proposed some years 
ago but was not applied back then.  I believe it is useful and should be 
considered for approval.

-------------- next part --------------
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8196442dd1..d98ebe46a4 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1792,6 +1792,12 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
     }
 
     for (;;) {
+        if (ff_check_interrupt(&s->interrupt_callback)) {
+           ret = AVERROR_EXIT;
+           av_log(s, AV_LOG_DEBUG, "interrupted\n");
+           return ret;
+        }
+
         AVPacketList *pktl = s->internal->packet_buffer;
 
         if (pktl) {


More information about the ffmpeg-devel mailing list