Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interrupt callback #170

Closed
gtow opened this issue Jun 30, 2015 · 6 comments
Closed

Interrupt callback #170

gtow opened this issue Jun 30, 2015 · 6 comments
Labels

Comments

@gtow
Copy link

gtow commented Jun 30, 2015

Hello,
I'm having problems with some inputs when using avformat_open_input, because some times it takes too long (arround 1:30) and then the function returns with the corresponding error. The problem is in the inputs, so the error is OK, but the timeout is too long.

So, I'm trying to use the method interrupt_callback from AVFormatContext, but I can't get it working. I don't know how to use the Callback_Pointer to define the interrupt function.
Please, Do you have some code or example using interrupt_callback?

Thank you very much

@saudet saudet added the question label Jul 1, 2015
@saudet
Copy link
Member

saudet commented Jul 1, 2015

Sure, there's some examples here: #124
http://libav-users.943685.n4.nabble.com/timeout-on-av-read-frame-td3306682.html
http://stackoverflow.com/questions/14558172/ffmpeg-av-read-frame-need-very-long-time-to-stop

It might also be possible to set a timeout through an option: #165

In any case, it's a feature that I would like to map to the setTimeout() property, so if you implement some interesting functionality, please be sure to send a pull request!! Thank you very much

@saudet saudet closed this as completed Jul 1, 2015
@gtow
Copy link
Author

gtow commented Jul 1, 2015

Thank you very much,
I've implemented the callback as you suggested in #124 with no problems. And the callback is called continuosly, except when I open a non valid input.
When I'm opening a non valid input with avformat_open_input, the callback isn't called during all the time the function is running (about 1:30), and then the function is called again (too late, because i want to abort it in 5-10 seconds).
I don't know if this could be a ffmpeg problem...

I don't use the FFmpegFrameGrabber, so i think i can't set a timeout as in #165. Is it possible to set this opion in the dictionary of avformat_open_input?

Thank you

@saudet
Copy link
Member

saudet commented Jul 2, 2015

Sounds like a bug in FFmpeg. Could you report that as an issue upstream? Thanks!

Even if you don't use FFmpegFrameGrabber, check the source code to see how the option gets set.

@gtow
Copy link
Author

gtow commented Jul 3, 2015

Ok, thank you very much

@hanamizukigakki
Copy link

hanamizukigakki commented Jul 25, 2016

@gtow I write the code as #124 suggested, but it returns a nullpointerException, could you please help me to solve it?

here is my code:

static final AVIOInterruptCB.Callback_Pointer dummy = new AVIOInterruptCB.Callback_Pointer() {
    @Override
    public int call(Pointer arg0) {
        return 1;
    }
};
...
AVFormatContext pFormatCtx = new AVFormatContext(null);
AVIOInterruptCB avioInterruptCB = new AVIOInterruptCB();
avioInterruptCB.callback(dummy);
pFormatCtx.interrupt_callback(avioInterruptCB);
...

and here is the ouput:

Exception in thread "Thread-0" java.lang.NullPointerException: This pointer address is NULL.
at org.bytedeco.javacpp.avformat$AVFormatContext.interrupt_callback(Native Method)

@saudet
Copy link
Member

saudet commented Jun 15, 2017

FYI, thanks to @d-a-gerashenko we now have working sample code for this:
https://github.com/bytedeco/javacv/blob/master/samples/FFmpegStreamingTimeout.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants