Optical mapping has been widely used in the study of cardiac electrophysiology in motion-arrested, ex vivo heart preparations. Recent developments in motion artifact mitigation techniques have made it possible to optically map beating ex vivo hearts, enabling the study of cardiac electromechanics using optical mapping. However, the ex vivo setting imposes limitations on optical mapping such as altered metabolic states, oversimplified mechanical loads, and the absence of neurohormonal regulation. In this study, we demonstrate optical electromechanical mapping in an in vivo heart preparation. Swine hearts were exposed via median sternotomy. Voltage-sensitive dye, either di-4-ANEQ(F)PTEA or di-5-ANEQ(F)PTEA, was injected into the left anterior descending artery. Fluorescence was excited by alternating green and amber light for excitation ratiometry. Cardiac motion during sinus and paced rhythm was tracked using a marker-based method. Motion tracking and excitation ratiometry successfully corrected most motion artifact in the membrane potential signal. Marker-based motion tracking also allowed simultaneous measurement of epicardial deformation. Reconstructed membrane potential and mechanical deformation measurements were validated using monophasic action potentials and sonomicrometry, respectively. Di-5-ANEQ(F)PTEA produced longer working time and higher signal/noise ratio than di-4-ANEQ(F)PTEA. In addition, we demonstrate potential applications of the new optical mapping system including electromechanical mapping during vagal nerve stimulation, fibrillation/defibrillation. and acute regional ischemia. In conclusion, although some technical limitations remain, optical mapping experiments that simultaneously image electrical and mechanical function can be conducted in beating, in vivo hearts.