Highlighting an area and record whatever goes inside the area

I’d like to know how to draw regions on the video capture then record whatever goes in that region. Similar to what is in this video:

Thank you in advance to whoever decides to help me!