[Libav-user] AVIOInterruptCB and how to use it
bsenftner at earthlink.net
bsenftner at earthlink.net
Fri Nov 12 17:31:51 EET 2021
Did you install an interrupt callback, and is it being called?
You should expect your installed callback will be called every av_read_frame() loop.
In my version using the change from the gist, I simply check the time since the last callback call, and if that time duration above a threshold my callback returns non-zero – indicating to av_read_frame() to return with AVERROR_EXIT.
If we are talking about a dropped communication, this is how one would test that: the time between receiving data exceeds a threshold, which is the same as the time between calls to the callback. What one’s software does in response to a timeout is another matter. Ffmpeg does nothing. In my code, I wait a user-settable duration and then do a fresh play request on that same url.
* Basically I'm trying to run an intercom style system
It sounds like you may want your I/O with something like server side events or WebSockets, in order to persist an open connection.
This may be of interest:
If need be, the contents of av_read_frame() is not very large, you could write your own variant for server side events or WebSockets.
For that, this may be of interest:
There may already be support for SSE and WebSockets in ffmpeg. I’m not very experienced with them, and do not track them.
From: Libav-user <libav-user-bounces at ffmpeg.org> On Behalf Of Simon Brown
Sent: Friday, November 12, 2021 7:33 AM
To: This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter. <libav-user at ffmpeg.org>
Subject: Re: [Libav-user] AVIOInterruptCB and how to use it
On Thu, 11 Nov 2021 at 22:06, <bsenftner at earthlink.net <mailto:bsenftner at earthlink.net> > wrote:
You may need a modified version of av_read_frame(). See this:
That’s for an earlier version of the libs, but you can see at line 31, the modification is simply providing a hook for the interrupt callback.
Thanks, that was really useful. And I notice that my version of the code doesn't have those lines in, so I added them in.
And I get the same result. I've rebuilt ffmpeg and re-installed the libraries following that change, and so I thought I'd also try seeing what happened if I just ran it using ffmpeg commandline.
The result was almost identical, but I put loglevel debug on to see what it was doing in av_read_frame when it hung, and I get NOTHING. So I'm back at square one.
Basically I'm trying to run an intercom style system, where data is sent when the push to talk button is on, and then the stream is stopped when it gets released. But when you press to talk again the whole thing is stalled and won't restart. I'm using the Opus codec.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user