Adding youtube videos in pdfs, html reports and html presentations

I got a question today on how to add a video to a beamer pdf presentation. Well, I had never done it, but I got curious enough to google around for a bit and here is the end product.

One way of doing it is using the media9 tex package. For this to work you need to have the latest version of texlive (or miktex). Then, it’s quite straight forward to include the video. The issue is that you have to open the pdf with Acrobat Reader 10+ (9 something works. I think that it’s 9.4.1+ but well, the point is that you need an updated version). You will also need a live web connection to actually show the video. An alternative (if you have the video file) is to convert it to swf and embed it. 

Here is my tex example file with the corresponding pdf output compiled using pdflatex. Remember that you need Acrobat Reader to actually see the video in the pdf.

After doing this, I just wanted to make some quick examples on how you can add a video to an html report using markdown (well, you add the video itself using html). I did it via knitr and Rstudio.

Example Rmd file with corresponding md and html * outputs from “knit HTML” in Rstudio.

Finally, the more interesting thing you can do is an html presentation which requires pandoc. Again, I used knitr to get things started and, while at it, add some R and math.

Example Rmd file with corresponding md and html * output from “knit HTML” in Rstudio. The slides are created from the md file using pandoc into this html ** file (main output in this case). 

Hopefully they’ll be useful to anyone venturing into embedding youtube videos in their presentations.

* These two files are very similar.

** html presentation.

Leonardo Collado-Torres
Leonardo Collado-Torres
Investigator @ LIBD, Assistant Professor, Department of Biostatistics @ JHBSPH

#rstats @Bioconductor/🧠 genomics @LieberInstitute/@lcgunam @jhubiostat @jtleek @andrewejaffe alumni/@LIBDrstats @CDSBMexico co-founder

comments powered by Disqus