Deprecated Warning: safeHtml
Since it appears that you are using Craft CMS 3, you can try the purify filter. 

In your code, change this line:

{% set vidcode = embed.isSafe() | trim('&lt;iframe') %}


To something like:

{% set vidcode = embed | purify | trim('&lt;iframe') %}


Documentation: