Commit afc4e5ceb1 for ffmpeg
commit afc4e5ceb1ccb92ae68eea7bf3ef6454ad199627
Author: Jun Zhao <barryjzhao@tencent.com>
Date: Fri Dec 4 23:26:41 2026 +0800
avformat/demux: back off nonblocking AVFoundation stream probing
Wait briefly after EAGAIN when probing a nonblocking AVFoundation
input so probing does not busy-wait for the next capture frame.
Other demuxers may consume input before returning EAGAIN, as when
NC skips an empty record directly or through concat.
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 324057bc3d..65c27fd422 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -2941,8 +2941,12 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
/* NOTE: A new stream can be added there if no header in file
* (AVFMTCTX_NOHEADER). */
ret = read_frame_internal(ic, pkt1);
- if (ret == AVERROR(EAGAIN))
+ if (ret == AVERROR(EAGAIN)) {
+ if ((ic->flags & AVFMT_FLAG_NONBLOCK) &&
+ !strcmp(ic->iformat->name, "avfoundation"))
+ av_usleep(1000);
continue;
+ }
if (ret < 0) {
/* EOF or error*/