bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.41k stars 1.57k forks source link

Modification of setFormat for VideoInputFrameGrabber #2107

Open Zjaun opened 9 months ago

Zjaun commented 9 months ago

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)

saudet commented 9 months ago

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

Zjaun commented 9 months ago

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?

saudet commented 9 months ago

It's in the FrameGrabber class.

saudet commented 9 months ago

It's in the FrameGrabber class.

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

Zjaun commented 9 months ago

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?

saudet commented 9 months ago

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