[Libav-user] avformat_open_input: adding a timeout

Ryan Grewatz grewa008 at d.umn.edu
Sat Jul 26 00:09:56 CEST 2014


Hello,

I'm currently writing a video streaming app that uses the ffmpeg libraries.
I'm dealing with a situation where I'm preparing an instance of
AVFormatContext by calling avformat_open_input. I'm using this over a
network under RTSP and I need to handle cases where a connection cannot be
established. I figured the best way to go about this is to add a connection
timeout of around 5-10 seconds, but I just can't seem to figure out how to
get this idea to work. Any help is greatly appreciated.

code:
    if(avformat_open_input(&formatCtx, "rtsp://192.168.0.100/1", NULL,
NULL)!=0){
        LOGI(".100 not working... trying .101");
        formatCtx = NULL;
        if(avformat_open_input(&formatCtx, "rtsp://192.168.0.101/1", NULL,
NULL)!=0)
            return -1; // Couldn't open file


Thanks!

--

Ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140725/fe103531/attachment.html>


More information about the Libav-user mailing list