diff --git a/libavformat/img2.c b/libavformat/img2.c
index 0610ae1ee5e2351412c1cbee91d442d6576da309..783167317c52af0b55da60b2a3774f8446c90361 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -269,6 +269,8 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
             return AVERROR(EIO);
         for(i=0; i<3; i++){
             if (url_fopen(&f[i], filename, URL_RDONLY) < 0) {
+                if(i==1)
+                    break;
                 av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename);
                 return AVERROR(EIO);
             }