December 2018 update:
I don't have an up-to-date Flarum install at the moment so if you're having issues with this extensions, try fof/formatting instead. Both extensions use the same underlying code.
To install: (run in the Flarum directory)
composer require s9e/flarum-ext-mediaembed:*
There are two ways to embed content: either by posting the URL as-is, or by using a [media]
BBCode.
https://twitter.com/Flarum/status/637106041876930564
[media]https://www.youtube.com/watch?v=wWarT7rqIYw[/media]
Here's the list of supported sites, depending on which version of s9e\TextFormatter is bundled in Flarum.