This is the method that I use and find it really handy. The main.php file for processwire.com has this at the top:
if(strpos($page->body, '<p>https://www.youtube.com') !== false) {
$replacement = '<iframe width="640" height="360" src="https://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>';
$page->body = preg_replace('#<p>\s*https://www.youtube.com/watch\?v=([^\s&<]+).*?</p>#iu', $replacement, $page->body);
}