There will have to be designated points where midroll ads can happen, just like the current system has, so the ads aren’t inserted mid-sentence or destroy an important sequence in the video. Nobody would accept it otherwise.
It’s a matter of detecting those points, mapping them to specific frames in the video, them automatically detecting when an ad is inserted on that basis.