We prove an explicit formula for periods of certain automorphic forms on SO5 × SO4 along the diagonal subgroup SO4 in terms of L-values. Our formula also involves a quantity from the theory of endoscopy, as predicted by the refined Gross–Prasad conjecture.