Error resilient video transcoding can insert error resilient tools in the compressed video to enhance error resilience of the video over wireless channels. However the error resilience insertion increases bit rate while reducing distortion. So the rate distortion optimization is required. In order to solve this problem,this paper proposes an error resilient video transcoding algorithm based on layered rate distortion optimization. This algorithm improves the flexibility by performing rate distortion optimization with different granularity for synchronization marker insertion and intra macroblock refresh on the frame layer and macroblock layer respectively. Moreover this algorithm improves the accuracy by accounting for the intra refresh,intra prediction,motion vector prediction on the frame layer and reduces the complexity by reducing the candidate macroblock modes on the macroblock layer. The simulation results show that the proposed algorithm improves PSNR by 0.6~1.1dB and reduces the complexity by about 25% compared with the algorithms based on single layer rate distortion optimization.