javacv
javacv copied to clipboard
Add method to FFmpegFrameGrabber to retrieve attached pic
I couldn't get the code to compile due to some missing imports and other errors, but I hope this works. Can you by any chance test this? #1876
What about adding a flag to the Frame object instead?
Im not sure I understand. Adding a flag to the frame object would help identify a frame with the attached pic. But I would still need to save a reference to the correct stream in the FFmpegFrameGrabber's startUnsafe() method, because finding the right stream is the bigger issue.
I see, what about having something like FrameGrabber.setVideoDisposition() to make the match?
Okay. So the way it would work is that you call setVideoDisposition(), then it finds the stream that contains an attached pic and sets the video stream to that. And then you would call frameGrabber.grabImage() like usual. Is that what you mean?
Yes, that sounds like something that could work well?
Please let me know if you have a better idea though. Thanks!
Sorry. I've been busy with school. Does this do the trick?
Something like that, yes, but add a property, just like for getVideoCodecName()/setVideoCodecName(), and use it in start().
What exactly should I do in the start() method?
Use the value of videoDisposition to set the videoStream, just like you did in your loop. Put that loop so it gets executed on start().
Did like you asked, but isn't the disposition only relevant for the FFmpegFrameGrabber and not all the other framegrabber types?
Sure, most of the properties there only apply to FFmpeg, but maybe in the future something else is going to become more popular and then that one will start using those properties.. Anyway, there is no disadvantage in providing an abstract class like this, only potential advantages, so let's just do it!
These changes look good. Did you test them to make sure they do what you need them to do?