Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7957885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:19:55+00:00 2026-06-04T04:19:55+00:00

I am writing some software that uses ffmpeg extensively and it is multi threaded,

  • 0

I am writing some software that uses ffmpeg extensively and it is multi threaded, with multiple class instances.

If the network connection drops out ffmpeg hangs on reading. I found a method to assign a callback that ffmpeg fires periodically to check if it should abort or not:

static int interrupt_cb(void *ctx) 
{ 

// do something 
    return 0;
} 

static const libffmpeg::AVIOInterruptCB int_cb = { interrupt_cb, NULL }; 

…

AVFormatContext* formatContext = libffmpeg::avformat_alloc_context( );
formatContext->interrupt_callback = int_cb; 
if ( libffmpeg::avformat_open_input( &formatContext, fileName, NULL, NULL ) !=0 ) {...}

This is all fine but nowhere on the web can i find what *ctx contains and how to determine whether the callback should return 1 or 0. I can’t assign a static “abort” flag as the class has many instances. I also can’t debug the code as for some reason visual studio refuses to set a breakpoint on the return 0; line, claiming no executable code is associated with the location. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:19:56+00:00Added an answer on June 4, 2026 at 4:19 am

    Found in the ffmpeg documentation:

    During blocking operations, callback is called with opaque as
    parameter. If the callback returns 1, the blocking operation will
    be aborted.

    Here is declaration int_cb variable of type AVIOInterruptCB struct from your code:

    static const libffmpeg::AVIOInterruptCB int_cb = { interrupt_cb, NULL };
    

    You declared opaque parameter as NULL.

    I’d recommend to rewrite initialization code like this:

    AVFormatContext* formatContext = libffmpeg::avformat_alloc_context( );
    formatContext->interrupt_callback.callback = interrupt_cb;
    formatContext->interrupt_callback.opaque = formatContext;
    

    you will be able to access formatContext instance inside interrupt_cb:

    static int interrupt_cb(void *ctx) 
    { 
        AVFormatContext* formatContext = reinterpret_cast<AVFormatContext*>(ctx);
    // do something 
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compile some software I've been writing in Linux that uses some
I'm writing some software that modifies a Windows Server's configuration (things like MS-DNS, IIS,
I'm interested in writing certain software that uses machine learning, and performs certain actions
I have a class that uses 'System.Net.Sockets.Socket' directly for network comunication, and currently I
My software uses multiple threads to do its work. There is a pipeline that
I am writing some testing software that receives some source code, compiles it on
I am writing some software that plots out fractals, and lets the user explore
We're currently writing some software that we want to protect. We thought that registering
I'm writing some software that automatically connects a Bluetooth device using the Windows Bluetooth
I'm writing some software that targets two versions of very similar hardware which, until

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.