With certain media files (wmv in particular), the very last frame will have a timestamp of AV_NOPTS_VALUE. This could cause the media to stick on that frame indefinitely. Instead, use the estimated next timestamp that was calculated in the previous frame.