diff --git a/libavformat/ftp.c b/libavformat/ftp.c
index 9aa7a45629..3474a0adbc 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -777,7 +777,11 @@ static int ftp_read(URLContext *h, unsigned char *buf, int size)
 {
     FTPContext *s = h->priv_data;
     int read, err, retry_done = 0;
-
+    if(s->position >= s->filesize)
+    {
+        ff_dlog(h,"ftp protocol reach file end\n");
+        return AVERROR_EOF;  
+    }
     ff_dlog(h, "ftp protocol read %d bytes\n", size);
   retry:
     if (s->state == DISCONNECTED) {
