You enter Thailand on a visa-exempt scheme or tourist visa, then you can apply for an in-country Non-O visa at your local immigration office. Then you go to the immigration office during you still have time of more than 15 WORKING days in Chiang Mai, apply for Non-O based on whatever you can meet the requirements.
Once your application is approved and your initial visa is inked into your passport, you wait for about 2 months and apply for a 1-year extension for the same reason.
Here is the general requirements for a Non-O based on being a spouse to a Thai. But you need to get ChaingMai office-specific requirements.
************************************************************************************************************************************************
*******
/6.FOR-PROVIDING-SUPPORT-TO-OR-BEING-A-DEPENDANT-OF-A-THAI-CITIZEN-SPOUSE-VISA-NON-O.pdf