<div dir="ltr"><div>You can add "timeout" to the options dictionary (avformat_open_input).</div><div><br></div><div>AVDictionary* opt = 0;</div><div>av_dict_set_int(&opt, "timeout", 1000000);</div><div></div><div>avformat_open_input(..., &opt);</div><div><br></div><div>For TCP this will set open/receive timeout to 1 second.</div><div><br></div><div>Best Regards,</div><div>Yurii<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">ср, 3 нояб. 2021 г. в 19:13, Simon Brown <<a href="mailto:simon.k.brown@gmail.com">simon.k.brown@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I am using av_read_frame to read from an incoming TCP audio stream, that was opened by avformat_open_input with ("tcp://<a href="http://127.0.0.1:62011?listen" target="_blank">127.0.0.1:62011?listen</a>") as the source file.<div><br></div><div>The server connects to this and sends the data, and av_read_frame returns frames of audio data that avcodec_decode_audio4 decodes for me.  All is fine.</div><div><br></div><div>Then the server stops sending for a bit, because it's asked to be paused, and then a short (or long) time later, it is asked to start again, but because the data is from a stream, not a file, the data is actually not a continuation of what came before, but essentially starts anew.  At this point av_read_frame stalls, and never returns a new frame, despite lots of data being pushed to it, and the ffmpeg libraries keeping the port open to receive the data.</div><div><br></div><div>So my question is a) can I force av_read_frame to return after a timeout, so that I can potentially handle a restart? or b) can av_read_frame be persuaded to restart itself if it can't synchronize to the incoming data?</div><div><br></div><div>Regards,</div><div>Simon</div></div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div>