Skip to content

ofGstVideoGrabber : Request width and height larger than format selected. #8436

@NickHardeman

Description

@NickHardeman

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

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions