[Libav-user] AVIOInterruptCB and how to use it

bsenftner at earthlink.net bsenftner at earthlink.net
Fri Nov 12 00:06:18 EET 2021


You may need a modified version of av_read_frame(). See this:

 

https://gist.github.com/bsenftner/ba3d493fa36b0b201ffd995e8c2c60a2

 

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.

 

-Blake

 

From: Libav-user <libav-user-bounces at ffmpeg.org> On Behalf Of Yurii Monakov
Sent: Thursday, November 11, 2021 12:57 PM
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

 

Hi,

 

Initial value of interrupt_callback can be cached internally somewhere inside avformat_find_stream_info.

My code performs assignment just right after context allocation. 

 

Regards,

Yurii

 

 

вт, 9 нояб. 2021 г. в 18:23, Simon Brown <simon.k.brown at gmail.com <mailto:simon.k.brown at gmail.com> >:

Hi,

I'm trying to stop av_read_frame from blocking when the stream is stopped (stream over TCP, and the sender pauses sending).  Reading various forum posts, it would appear that I need to use the AVIOInterruptCB structure and assign it to my format context.  So I do this:

 

    /* retrieve stream information */
    if (avformat_find_stream_info(fmt_ctx, NULL) < 0) {
        fprintf(stderr, "Could not find stream information\n");
        exit(1);
    }
    static const AVIOInterruptCB int_cb = {interrupt_cb, &int_cb_ctx};
    fmt_ctx->interrupt_callback = int_cb;

 

where interrupt_cb and int_cb_ctx are defined as:

 

static int interrupt_cb(void *ctx)
{
int *p = (int *)ctx;
*p = 53;
return 1;
}

int int_cb_ctx = 0;

The only problem now is that av_read_frame still blocks, there's no evidence that interrupt_cb is being called, and I cannot restart my stream because my decoder gets stuck in av_read_frame.

 

Is there anything I am doing wrong?  Or is this a feature that has been deprecated?  Is there a better way of getting out of av_read_frame blocking?

 

Cheers,

Simon

_______________________________________________
Libav-user mailing list
Libav-user at ffmpeg.org <mailto:Libav-user at ffmpeg.org> 
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
libav-user-request at ffmpeg.org <mailto:libav-user-request at ffmpeg.org>  with subject "unsubscribe".

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20211111/db1cc6b5/attachment.htm>


More information about the Libav-user mailing list