Idea for organic keyframe

Hello, Can you tell me please how to retrieve focus data from a real camera footage and apply it to a digital focus effect? Focus will be hard with key-frames. Thanks in advance.