Re: [FFmpeg-devel] fix ftp hang up because not return AVRRROR_EOF

2018-06-13 Thread Jan Ekström
On Wed, Jun 13, 2018 at 1:27 PM, Gj X  wrote:
> fix:
> 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) {
>

Hi,

Thanks for your contribution. I just looked at that function and it
seems like `ftp_read` needs some improvement.

But staying on the 0 != EOF fixup topic, probably something like this
should prod it to work:

diff --git a/libavformat/ftp.c b/libavformat/ftp.c
index 9aa7a45629..f07e9fcdd9 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -783,13 +783,13 @@ static int ftp_read(URLContext *h, unsigned char
*buf, int size)
 if (s->state == DISCONNECTED) {
 /* optimization */
 if (s->position >= s->filesize)
-return 0;
+return AVERROR_EOF;
 if ((err = ftp_connect_data_connection(h)) < 0)
 return err;
 }
 if (s->state == READY) {
 if (s->position >= s->filesize)
-return 0;
+return AVERROR_EOF;
 if ((err = ftp_retrieve(s)) < 0)
 return err;
 }
@@ -823,7 +823,7 @@ static int ftp_read(URLContext *h, unsigned char
*buf, int size)
 goto retry;
 }
 }
-return read;
+return read ? read : AVERROR_EOF;
 }

 av_log(h, AV_LOG_DEBUG, "FTP read failed\n");
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] fix ftp hang up because not return AVRRROR_EOF

2018-06-13 Thread Gj X
fix:
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) {


use follow command hang up

./ffmpeg -loglevel level+debug -i ftp://chiwailam:"abcd1234!"@
192.168.1.114/orgvideos/9926558478.avi -f null -

ffmpeg version:

 libavutil  56. 14.100 / 56. 14.100
  libavcodec 58. 18.100 / 58. 18.100
  libavformat58. 12.100 / 58. 12.100
  libavdevice58.  3.100 / 58.  3.100
  libavfilter 7. 16.100 /  7. 16.100
  libswscale  5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc55.  1.100 / 55.  1.100


ftp_hang_because_not_return_eof.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel