Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed local Video in R Markdown?

I already know how to embed the youtube video in the R Markdown document. But Suppose I have offline video, that I do not want to publish, in mp4 or avi format. Is there a way to embed it in the document? Something like the following (taking inspiration from image embedding):

![Caption](vid/video1.mp4)
like image 953
Harmanjit Singh Avatar asked May 08 '17 06:05

Harmanjit Singh


People also ask

How do I add a video to R Markdown?

embed_video() provides a standard way to embed video in R Markdown documents when the output format is HTML, and to print placeholder text when the output format is not HTML.

How do I embed code in R Markdown?

You can insert an R code chunk either using the RStudio toolbar (the Insert button) or the keyboard shortcut Ctrl + Alt + I ( Cmd + Option + I on macOS).

How do I embed an image in R Markdown?

To add an image in markdown you must stop text editing, and you do this with the command [Alt text] precedeed by a ! Then you have to add the path to the image in brackets. The path to the image is the path from your directory to the image.

What is the difference between RStudio and R Markdown?

To put it simply - R is the actual programming language, RStudio is a convenient interface in which to use it, and R Markdown is a specific type of file format designed to produce documents that include both code and text.


1 Answers

This worked for me:

Slide With Code
========================================================
<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
</video>

If you remove the width and height, and enable

autosize: true

R takes care of the size of the video.

like image 145
Mat D. Avatar answered Sep 20 '22 02:09

Mat D.