Using real-time spectroscopic ellipsometry, we directly observed a reversible lattice and electronic structure evolution in SrCoOx (x = 2.5 - 3) epitaxial thin films. Drastically different electronic ground states, which are extremely susceptible to the oxygen content x, are found in the two topotactic phases, i.e. the brownmillerite SrCoO2.5 and the perovskite SrCoO3. First principles calculations confirmed substantial differences in the electronic structure, including a metal-insulator transition, which originates from the modification in the Co valence states and crystallographic structures. More interestingly, the two phases can be reversibly controlled by changing the ambient pressure at greatly reduced temperatures. Our finding provides an important pathway to understanding the novel oxygen-content-dependent phase transition uniquely found in multivalent transition metal oxides.