Embed video

Ian Lyttle



Using this package, you can embed videos into RMarkdown documents and Shiny apps for videos from:

The links above are associated with the embedding API for each of the services; these are the APIs wrapped by the embed() functions in this package. You can also embed the video using only the URL of the page your video is on, with embed_url().

To set the start time, or to change the formatting, check out the use_*() functions in vignette("modify").

Embded using URL

Although a URL can be long and awkward, it will get the job done. If the URL is from one of the supported services, it should just work:


If you would like to generate more-concise code using the URL, you can use the suggest_embed() function:

#>   embed_youtube("BD_n6ju9iRA")

Embed by service


You can get your video’s identifier by inspecting its URL at YouTube - you can use the short version, as well:

#>   embed_youtube("JeaBNAXfHfQ")

The identifier is the last part of the URL. To embed this video:



For Vimeo, the identifier is also included in the standard URL:

#>   embed_vimeo("238200347")

The Vimeo identifier is the path of the URL:



To share a video on Box, the video file itself will have to be shared. From the Box web-interface, you can do this by clicking the Share button at the top-right corner of your file’s web-page. Then create a Share Link:

Then, you need to capture some information about the embed-link itself, either the URL or the id. Please note that you need to work with the “ugly” URL, not a custom URL:

#>   embed_box("d75g9cr27s2jnx62b86idpgffzzxfdt2")

You can do the same thing using the embed_box() function and the id. The Box identifier is the last part of the path, in this case d75g9cr27s2jnx62b86idpgffzzxfdt2.


If you are using a corporate instance of Box, and use the embed_box() function, you will also have to specify the custom_domain. For example, if your URL starts with "https://acme.app.box.com", then your custom_domain is "acme".

Microsoft Stream

Microsoft Stream is a service offered for use by (large) organizations so that they may share videos internally to their organization. As such, this functionality may have limited appeal.

#>   embed_msstream("ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48")

The identifier is the last part of the path of the URL, in this case ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48.

embed_msstream("ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48") %>%
  use_rounded() %>%

Because this video is internal to an organization, it will likely not play for you.

Sample videos

In case you need sample videos with which to experiment, this package has you covered:


Also (mercifully, not displayed as it seems no-longer embeddable):