I am trying to add timeout to the function avformat_open_input using dictionary options.
here is my code.
AVDictionary *dict = NULL; // "create" an empty dictionary
av_dict_set(&dict, "timeout", "6000", 0); // add an entry
if (avformat_open_input(&av_format_ctx, "rtmp://192.168.1.2:1935/live/sum", NULL, &dict) < 0) {
return false;
}
but the function does not wait for 6 seconds it exits immediately after being called.
I know it is an old question, but anyhow... The timeout option is used in listen mode. According to the ffmpeg documentation:
timeout Set maximum timeout (in seconds) to wait for incoming connections. A value of -1 means infinite (default). This option implies the rtsp_flags set to listen.
Check the console after the error when trying to set the timeout option. I bet it is saying that it could not open the rtsp for listening. Use stimeout:
stimeout Set socket TCP I/O timeout in microseconds.
Pay double attention on the number of zeros (microseconds)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With