This paper focuses on automatic guided vehicle (AGV) trajectory planning in the presence of moving obstacles with known but complicated trajectories. In order to achieve good solution precision, optimality and unification, the concerned task should be formulated as an optimal control problem, and then discretized into a nonlinear programming (NLP) problem, which is numerically optimized thereafter. Without a near-feasible or near-optimal initial guess, the NLP-solving process is usually slow. With the purpose of accelerating the NLP solution, a search-based rough planning stage is added to generate appropriate initial guesses. Concretely, a continuous state space is formulated, which consists of Cartesian product of 2D configuration space and a time dimension. The rough trajectory is generated by a graph-search based planner, namely the A* algorithm. Herein, the nodes in the graph are constructed by discretizing the aforementioned continuous spatio-temporal space. Through this first-search-then-optimization framework, optimal solutions to unified trajectory planning problems can be obtained fast. Simulations have been conducted to verify the real-time performance of our proposal.