[Libav-user] AVIOInterruptCB and how to use it

Simon Brown simon.k.brown at gmail.com
Tue Nov 9 17:22:40 EET 2021


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20211109/4df96d4b/attachment.htm>


More information about the Libav-user mailing list