Fix bug causing frames to be missed when encoding.