Re: [FFmpeg-devel] [PATCH] avformat/utils.c: allows av_read_frame to return after a timeout period.

2019-12-02 Thread gga


On 1/12/19 09:05, Andreas Rheinhardt wrote:

ggarr...@gmail.com:

From: Gonzalo Garramuño 

Moved the check inside and at the end of the if (pktl) as per Michael 
Niedermayer's suggestion.
This patch is based on one from Blake Senftner ( bsenftner at earthlink.net ).

The hanging in av_read_frame can be reproduced with an rtmp stream that is 
aborted midway and ffplay (for example) playing that stream.
---
  libavformat/utils.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8196442dd1..653918d5a5 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1836,6 +1836,11 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
 
>internal->packet_buffer_end, pkt);
  goto return_packet;
  }
+
+if (ff_check_interrupt(>interrupt_callback)) {
+av_log(s, AV_LOG_DEBUG, "interrupted\n");
+return AVERROR_EXIT;
+}
  }
  
  ret = read_frame_internal(s, pkt);

This patch makes it possible for pkt to be still uninitialised after

the call to av_read_frame() if I am not mistaken (namely if the packet
list was initially not empty and the interrupt was triggered before
read_frame_internal() has been called). If so, this clashes with a
recently proposed patch by me
(https://ffmpeg.org/pipermail/ffmpeg-devel/2019-December/253662.html).
One could either allow av_read_frame() to return unclean packets on
error or you would have to add the necessary initializations in your
code (or you would have to make sure that your code is not triggered
before the first call to read_frame_internal()).

- Andreas
I am afraid I do not know enough of the ffmpeg internals to make the 
initialization changes you propose.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/utils.c: allows av_read_frame to return after a timeout period.

2019-11-29 Thread gga

On 29/11/19 15:35, Michael Niedermayer wrote:


also, do we have a testcase where this loop hangs ?
if not please provide a testcase
I don't have an easy testcase, but it can be seen with any rtmp stream.  
A full test case can be reproduced like this:


Compile and create a nginx server like it is specified here:

 https://github.com/arut/nginx-rtmp-module/wiki/Getting-started-with-nginx-rtmp

Start the nginx server:
/usr/local/nginx/sbin/nginx

Start ffmpeg streaming:
ffmpeg -re -i long.mov -c copy -f flv rtmp://localhost/myapp/mystream

In another window, play the stream:
ffplay rtmp://localhost/myapp/mystream

Now, abort the ffmpeg process by CTRL-C.  ffplay will eventually hang 
and not allow it to close it when clicking on the close window button.  
With the patch, ffplay will eventually become responsive once again 
after the timeout period.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/utils.c: allows av_read_frame to return after a timeout period.

2019-11-26 Thread gga



On 26/11/19 14:31, Michael Niedermayer wrote:

On Thu, Nov 21, 2019 at 06:27:10PM -0300, ggarr...@gmail.com wrote:

From: Gonzalo Garramuño 

This patch is based on a patch by bsenftner at earthlink.net.
---
  libavformat/utils.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8196442dd1..c3c2c77c0c 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1838,6 +1838,11 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
  }
  }
  
+if (ff_check_interrupt(>interrupt_callback)) {

+av_log(s, AV_LOG_DEBUG, "interrupted\n");
+return AVERROR_EXIT;
+}
+

I think this can be moved into the if() above, which might
reduce the number of calls.

thx
[...]

It would probably reduce only one call, as pktl (the if above) is a list 
that will get filled probably as soon as there is a packet.  Or maybe I 
am reading the code wrong?  Also, if it does not get filled, we probably 
want to exit anyway, too.


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/utils.c: allows av_read_frame to return after a timeout period.

2019-11-24 Thread gga

Friendly ping.  Does the patch need anything else for approval?

On 21/11/19 18:27, ggarr...@gmail.com wrote:

From: Gonzalo Garramuño 

This patch is based on a patch by bsenftner at earthlink.net.
---
  libavformat/utils.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8196442dd1..c3c2c77c0c 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1838,6 +1838,11 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
  }
  }
  
+if (ff_check_interrupt(>interrupt_callback)) {

+av_log(s, AV_LOG_DEBUG, "interrupted\n");
+return AVERROR_EXIT;
+}
+
  ret = read_frame_internal(s, pkt);
  if (ret < 0) {
  if (pktl && ret != AVERROR(EAGAIN)) {


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] av_read_frame timeout

2019-11-18 Thread gga


El 18/11/19 a las 14:12, Michael Niedermayer escribió:

On Sun, Nov 17, 2019 at 06:37:58PM -0300, gga wrote:

The following patch adds a timeout interrupt to av_read_frame to prevent it
from hanging up the application.  This patch was proposed some years ago but
was not applied back then.  I believe it is useful and should be considered
for approval.

If this was proposed previously please provide a link to the previous patch/
discussion

Thanks

[...]


I only have the link to the proposed patch, not the discussion, as I did 
not write the patch.


https://ffmpeg.org/pipermail/libav-user/2017-February/010086.html

Paul B Mahol also asked in the libav-user list about the discussion to the 
person who wrote the patch and who would be more qualified than me to state why 
it was rejected back then.  Sorry I cannot be more helpful.  I tried searching 
the archives with google with no success, as not even the above email shows up 
(and I tried several terms).

Thanks.


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] av_read_frame timeout

2019-11-17 Thread gga
The following patch adds a timeout interrupt to av_read_frame to prevent 
it from hanging up the application.  This patch was proposed some years 
ago but was not applied back then.  I believe it is useful and should be 
considered for approval.


diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8196442dd1..d98ebe46a4 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1792,6 +1792,12 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
 }
 
 for (;;) {
+if (ff_check_interrupt(>interrupt_callback)) {
+   ret = AVERROR_EXIT;
+   av_log(s, AV_LOG_DEBUG, "interrupted\n");
+   return ret;
+}
+
 AVPacketList *pktl = s->internal->packet_buffer;
 
 if (pktl) {
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".