Kris,
Mike's advice is good. You should contact the consulate for the area where you live. You probably will not be able to enter Brazil on the work visa since you are not working there anymore. I'm sure you will have to go through the whole process of permanency based on marriage. To answer you question being in Brazil to do it. You can do it at a consulate or the PF in Brazil. Either way you finalize it with the PF in Brazil.
Jim