We develop a technique to analyze pulsed thermography videos in order to detect and reconstruct subsurface defects in homogeneous and layered objects. The technique is based on the analysis of the thermal response of an object to a heat pulse. This thermal response is compared to the predictions of a finite-difference model that is systematically and progressively adjusted to minimize a cost function. With this minimization process, we obtain a depth and a thickness function that allow us to determine the three-dimensional shape, size, depth, thickness, and location of internal defects. The detected defects are reliably reconstructed with graphics of easy interpretation.