We propose a scheme for controlling the quantum interface between the travelling optical wave packet and microwave photonic memory. The effective coupling between the optical and microwave modes is mediated by the rare earth doped crystal as first proposed by Williamson et al. [ L.A. Williamson, Y.H. Chen, J.J. Longdell, Phys. Rev.Lett. 113, 203601 (2014)], and can be modulated by a time-dependent coherent driving field. With the effective model, we obtain the fidelity of the write process for arbitrary input wave packet as well as driving field, and investigate its optimization in two cases. In the first case of constant coupling, the optimal input wave packet is analytically derived to maximize the fidelity, while in the latter case of tunable coupling, the sequence of coherent driving field is numerically optimized for arbitrary given input wave packet. The write process for the Gaussian input wave packet can be explicitly characterized in the tunable parameter regime of real experiments, revealing that the fidelity can reach 0.974η (η being the coupling efficiency of the optical cavity). Based on these advantages, the proposal will have potential applications for the investigation of quantum networks.