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 <[email protected]> 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. <[email protected]>
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 <[email protected] 
<mailto:[email protected]> >:

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
[email protected] <mailto:[email protected]> 
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[email protected] <mailto:[email protected]>  with 
subject "unsubscribe".

_______________________________________________
Libav-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to