You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using an SDP file to stream RTP to pyav. I get the frames in a thread.
The timeout argument for av.open() seems to be capped at around 20 seconds. I need to be able to wait for a period longer than 20 seconds, but the container always times out.
EDIT: While writing this bug report, I did find a possible fix by using the FFmpeg arg listen_timeout.
Expected behavior
I would expect the open en read timeout to be configurable above 20s using the specified (float) values.
Actual behavior
When no stream is available, av.open times out after 20s when a higher time is specified.
Traceback:
Exception in thread Thread-1 (get_frame):
Traceback (most recent call last):
File "threading.py", line 1016, in _bootstrap_inner
File "threading.py", line 953, in run
File "pyav_get_frames.py", line 71, in get_frame
File "av\container\input.pyx", line 202, in decode
File "av\container\input.pyx", line 162, in demux
File "av\container\core.pyx", line 292, in av.container.core.Container.err_check
File "av\error.pyx", line 336, in av.error.err_check
av.error.UndefinedError: [Errno 138] Error number -138 occurred: 'C:\\dir\\rtpstream.sdp'; last error log: [h264] error while decoding MB 79 36
Investigation
I've tried a selection of values, 3, 5 and 10 all work as expected.
When using a value above 20 (30, 60, etc.), the timeout is still at around 20 seconds.
I have tried to specify the timeout with the ffmpeg args as well: options={"protocol_whitelist": "file,udp,rtp", "timeout":"30000"}
importavfromcollectionsimportdequefromthreadingimportThreadclassGetFrames:
def__init__(self):
# Setup thread to read frames from the video stream.self.thread=Noneself.input_video=Noneself.deque=deque(maxlen=2)
defstart_streaming(self, sdp_path):
# Open the RTP stream.self.input_video=av.open(sdp_path, options={"protocol_whitelist": "file,udp,rtp"}, timeout=30.0)
stream=self.input_video.streams.video[0]
stream.codec_context.skip_frame="NONKEY"# Get one frame to initialize the buffer.self.get_frame(once=True)
# Setup thread to read frames from the video stream.self.thread=Thread(target=self.get_frame, args=(), daemon=True)
self.thread.start()
defget_frame(self, once=False):
forframeinself.input_video.decode():
self.deque.append(frame) # Circular bufferifonce:
return
Overview
I am using an SDP file to stream RTP to pyav. I get the frames in a thread.
The timeout argument for av.open() seems to be capped at around 20 seconds. I need to be able to wait for a period longer than 20 seconds, but the container always times out.
EDIT: While writing this bug report, I did find a possible fix by using the FFmpeg arg listen_timeout.
Expected behavior
I would expect the open en read timeout to be configurable above 20s using the specified (float) values.
Actual behavior
When no stream is available, av.open times out after 20s when a higher time is specified.
Traceback:
Investigation
I've tried a selection of values, 3, 5 and 10 all work as expected.
When using a value above 20 (30, 60, etc.), the timeout is still at around 20 seconds.
I have tried to specify the timeout with the ffmpeg args as well:
options={"protocol_whitelist": "file,udp,rtp", "timeout":"30000"}
I found that the default value is 20, which I can indeed confirm.
Possible cause/fix:
After reading the commit diff, I tried to use listen_timeout;
And that did work! Note, this is value is probably in seconds for RTP...
Reproduction
rtpstream.sdp:
pyav_get_frames.py:
I handle the frames in the buffer elsewhere.
Versions
Research
I have done the following:
Additional context
The text was updated successfully, but these errors were encountered: