Calculation of vibrational frequencies using molecular trajectories