Cant give a reduced code example right not because my Advanced Responsive Video Embedder plugin is somewhat complicated. But the exact same code is used to generate the embeds, its just through shortcode or autoembed.
I generate the exact same content with shortcodes or with autoembeds. Wordpress ads a
<p> and a
<br> to the content put out when I embed videos with autoembeds but not when I embed it with shortcodes.
The HTML does not has any line breaks in it. Is seems wordPress is treating the output as normal content and thats probably results in putting a
<p> arround a HTML comment and and a
<br> after a
<img>. My guess is that WP does not do this for content from shortcodes but for autoembeds.
Is there a way to prevent this? I know a way to remove it with JS later but my base plugins functionality has no JS file at all anf it would feel hacky and bloated for me to add one just for that.