openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

ofGstVideoGrabber : Request width and height larger than format selected.

Open NickHardeman opened this issue 8 months ago • 0 comments

Testing on linux mint 22.1 and the nightly.

I have an older 720p webcam. When I request 1920x1080 for more compatibility with newer devices, the old one fails to open. Without having to loop through formats and do a manual check, was hoping it would select a format resolution that it does support and open it.

Testing with the following code opens the camera be adjusting the w and h variable if it is too large for the format.

ofGstVideoFormat format;
if(internalPixelFormat!=OF_PIXELS_NATIVE){
        format = selectFormat(w, h, attemptFramerate, internalPixelFormat);
        ofLogNotice("ofGstVideoGrabber") << "initGrabber(): selected device: " << camData.webcam_devices[deviceID].product_name;
        ofLogNotice("ofGstVideoGrabber") << "initGrabber(): selected format: " << format.width << "x" << format.height <<  " " << format.mimetype << " " << format.format_name << " framerate: " << format.choosen_framerate.numerator << "/" << format.choosen_framerate.denominator;
        	
        if( format.width < w ) {
        	ofLogNotice("ofGstVideoGrabber") << "initGrabber(): setting the width to " << format.width;
        	w = format.width;
        }
        if( format.height < h ) {
        	ofLogNotice("ofGstVideoGrabber") << "initGrabber(): setting the height to " << format.height;
        	h = format.height;
        }
}

Changing https://github.com/openframeworks/openFrameworks/blob/32971e8a7e7474c6b598834f0ae25a2f01a404f4/libs/openFrameworks/video/ofGstVideoGrabber.cpp#L717-L722

NickHardeman avatar Apr 23 '25 14:04 NickHardeman