How to ensure height vs width ratio?

With the snippet below, which works fine most of the time, but i occasionally see users being changed from 640x360 to 640x480 or other dimensions that are not having the same ratio and cause the vertibal black bars. Can I avoid this in any way? Thanks

constraints: {
         video: {
             height: {
                 max: 360,
                 ideal: 360
             }           
             , width: {
                 max: 640,
                 ideal: 640
             }
             
        }    
     }

Not tested but the following might work

    constraints: {
        video: {
            aspectRatio: 16 / 9,
            height: {
                ideal: 360,
                max: 480,
                min: 240
            }
        }
    },

It seems to help (even though jitsi has removed the aspectRatio from their doc, but i guess it is more like a WebRtc standard? not sure but seems a higher probability of keeping the ratio, nice man thanks