A novel swing control scheme combining optimization and input-shaping techniques is proposed for overhead cranes subjected to parameter variations and modeling errors. An input shaper was first designed using the analytical method based on the linear swing dynamic model. Then, the particle swarm optimization algorithm was used to optimize the pulse amplitudes and time of the shaper to reduce the influence of modeling errors on the residual vibration. Furthermore, an adaptive optimization method was also used to optimize the parameters of the shaper to suppress the influence of the change in the payload mass and the rope length on the residual vibration. The proposed control scheme can suppress the influence of uncertainties on residual vibration and improve the anti-disturbance ability of a closed-loop system via offline and online dual optimization. Finally, the simulation results verify the effectiveness of the scheme.