Search code examples
ffmpeglibavlibavformat

what is the subtitute for avio_set_interrupt_cb?


Is the avio_set_interrupt_cb deprecated in the new ffmpeg release? What is the substitute?


Solution

  • I found the answer myself. Here is how it's done

    You define the call back

    int decode_interrupt_cb(void * ctx) {
        return isQuit;
    }
    

    Make a call back struct

    const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
    

    Assign it to you AVFormatContext's interrupt_callback before any file reading

    pFormatCtx->interrupt_callback = int_cb;
    

    if you open file with 'avio_open2', use it like this:

    int errCode = avio_open2(&pFormatCtx->pb, filename, AVIO_FLAG_READ, &pFormatCtx->interrupt_callback, NULL);
    

    Hope someone find it helpful.