Video Embed in FieldFormatter I want to embed the video as follows. I have written a FieldFormatter for this. 

public function viewElements(FieldItemListInterface $items, $langcode) {
    $element = [];

    foreach ($items as $delta =&gt; $item) {
      // Render each element as markup.
        $target_id = $item-&gt;getValue()['target_id'];

        $file = \Drupal\file\Entity\File::load($target_id); //load the file and its attribute.        
        $parts = pathinfo($file-&gt;getFileUri());
        $new_filename = $parts['filename'] . '_' . $file-&gt;getCreatedTime() .'_selfhelpvideofid_' . $target_id . '.' . $parts['extension'];            

        $video = '&lt;video width="480" height="320" controls="controls"&gt;
                    &lt;source src="movie.mp4"  type="video/mp4"&gt;
                  &lt;/video&gt;';    

      $element[$delta] = [
        '#type' =&gt; 'markup',
        '#markup' =&gt; $video,
      ];
    }

    return $element;
  }


The above is not working. Please help.
Instead of #markup, which is filtered, use inline template:

$file_path = 'movie.mp4'

$video = '&lt;video width="480" height="320" controls="controls"&gt;
  &lt;source src="{{ file_path }}"  type="video/mp4"&gt;
&lt;/video&gt;';

$element[$delta] = array(
  '#type' =&gt; 'inline_template',
  '#template' =&gt; $video,
  '#context' =&gt; array(
    'file_path' =&gt; $file_path,
  ),
);