We report about an in situ study of crystalline structural changes during thermal treatment of a Ba0.5Sr0.5TiO3 (BSTO) film grown on MgO. The study covers the complete cycle of heating, annealing and cooling and reveals simultaneous phenomena of phase transitions and strain evolution, which have been characterized by in situ 2D reciprocal space mapping (2D-RSM) using high-resolution synchrotron x-ray diffraction in coplanar and grazing incidence geometries. In this way, temperature induced phase transformation from the BSTO2 to the BSTO1 phase has been monitored and the appearance of a further crystalline phase was detected. Moreover, for both BSTO phases, transitions between in-plane compressive and tensile states have been determined during thermal treatment. Furthermore, a contraction of the out-of-plane lattice components has been observed during the annealing phase while the in-plane lattice components remain leading to the change of the residual in-plane strain towards tensile state. The in situ 2D-RSM findings provide valuable and versatile insights into strain engineering and structure modification upon thermal treatment.