This paper studies an algorithm of automatic target tracking based on PTZ system. Select the tracking target and set up the target motion trajectory in the video screen. Along the motion trajectory, the system controls the PTZ rotation automatically to track the target real-timely. At the same time, it adjusts the zoom to enlarge or reduce to make sure the target can display on the video screen center clearly at the suitable size. By testing on groups of video, verify the effectiveness of the automatic target tracking algorithm.