Ultrafast infrared spectroscopy reveals the structural and dynamical heterogeneity of glassy materials