javacv icon indicating copy to clipboard operation
javacv copied to clipboard

Add method to FFmpegFrameGrabber to retrieve attached pic

Open Tengyyy opened this issue 1 year ago • 10 comments

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

Tengyyy avatar Aug 26 '22 20:08 Tengyyy

What about adding a flag to the Frame object instead?

saudet avatar Aug 26 '22 23:08 saudet

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.

Tengyyy avatar Aug 27 '22 09:08 Tengyyy

I see, what about having something like FrameGrabber.setVideoDisposition() to make the match?

saudet avatar Aug 27 '22 14:08 saudet

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?

Tengyyy avatar Aug 27 '22 23:08 Tengyyy

Yes, that sounds like something that could work well?

saudet avatar Aug 27 '22 23:08 saudet

Please let me know if you have a better idea though. Thanks!

saudet avatar Sep 07 '22 00:09 saudet

Sorry. I've been busy with school. Does this do the trick?

Tengyyy avatar Sep 09 '22 18:09 Tengyyy

Something like that, yes, but add a property, just like for getVideoCodecName()/setVideoCodecName(), and use it in start().

saudet avatar Sep 09 '22 23:09 saudet

What exactly should I do in the start() method?

Tengyyy avatar Sep 16 '22 16:09 Tengyyy

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().

saudet avatar Sep 16 '22 23:09 saudet

Did like you asked, but isn't the disposition only relevant for the FFmpegFrameGrabber and not all the other framegrabber types?

Tengyyy avatar Sep 29 '22 12:09 Tengyyy

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?

saudet avatar Sep 29 '22 22:09 saudet