javacv icon indicating copy to clipboard operation
javacv copied to clipboard

Modification of setFormat for VideoInputFrameGrabber

Open Zjaun opened this issue 10 months ago • 6 comments

Since the current implementation of VideoInputFrameGrabber does nothing, I modified the statements inside the start() method of the class. In this change, developers can now set the format/subtype of that FrameGrabber. They can now use MJPEG instead of the default media format.

PS: Tried setting the grabber's resolution to 1080p with MJPEG, and the image is black. It's not black if the resolution is lower than that (only happens if you called the grab() method for the first time, the image isn't black after that)

Zjaun avatar Oct 03 '23 10:10 Zjaun

The values of that look more like video codecs, so we could maybe pick the value from videoCodec instead?

saudet avatar Oct 03 '23 11:10 saudet

I based my changes only in videoInputLib.java (link), can you guide me where is the videoCodec located so that I can take a look?

Zjaun avatar Oct 03 '23 11:10 Zjaun

It's in the FrameGrabber class.

saudet avatar Oct 03 '23 12:10 saudet

It's in the FrameGrabber class.

So that you could call videoInputGrabber.setVideoCodec(VI_MEDIASUBTYPE_MJPG) to do what you need. Sounds good?

saudet avatar Oct 03 '23 22:10 saudet

Oohh, a new function (I guess) that is not implemented directly in the VideoInputFrameGrabber. I think I may have to comb through the FrameGrabber class and add the methods not implemented to the VideoInputFrameGrabber. Is the parameter for setVideoCodec the same as setRequestedMediaSubType?

Zjaun avatar Oct 04 '23 13:10 Zjaun

No need to add new methods, just use the value of the videoCodec field variable.

saudet avatar Oct 04 '23 13:10 saudet