How to include multimedia files in beamer

media9 package

  • information can be found in the documentation
  • usage (2code examples to be compiled as separate documents):
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% player (`VPlayer.swf`) and video resource (`eso50supernova.m4v`)
% embedded in the document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{beamer}
\usepackage{media9}

\begin{document}
\begin{frame}{embedded files}

\includemedia[
  width=0.4\linewidth,
  totalheight=0.225\linewidth,
  activate=pageopen,
  passcontext,  %show VPlayer's right-click menu
  addresource=eso50supernova.m4v,
  flashvars={
    %important: same path as in `addresource'
    source=eso50supernova.m4v
  }
]{\fbox{Click!}}{VPlayer.swf}

\end{frame}
\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% player (`VPlayer.swf`) and video resource (`eso50supernova.m4v`)
% loaded from web urls during viewing time
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{beamer}
\usepackage{media9}

\begin{document}
\begin{frame}{remote files}

\includemedia[
  width=0.4\linewidth,
  totalheight=0.225\linewidth,
  activate=pageopen,
  passcontext,  %show VPlayer's right-click menu
  flashvars={
    source=https://cdn.eso.org/videos/medium_podcast/eso50supernova.m4v
  }
]{\fbox{Click!}}{http://mirrors.ctan.org/macros/latex/contrib/media9/players/VPlayer.swf}

\end{frame}
\end{document}
  • file types:

    • SWF (Flash); PRC, U3D (3D content, local files only)
    • MP4 (h264 encoded), FLV, MP3 via configurable media players, e. g. VPlayer.swf and APlayer.swf bundled with media9
    • any file type a user-provided SWF app can digest; example: the slide show viewer SlideShow.swf bundled with media9, example on TeX-SX
  • important note:

  • viewer:

    • Windows: Acrobat Reader, Foxit (configuration), PDF-XChange, all requiring Adobe Flash Player plugin for Firefox (not the ActiveX version)
    • Linux (x86): only outdated Adobe-Reader-9.4.1 and using VPlayer9.swf/APlayer9.swf is available natively, Current adobe reader and flash can be installed via wine (see https://tex.stackexchange.com/a/446179/36296)
    • OSX: Acrobat Reader (Adobe Flash Player plugin required)
    • mobile: not supported

multimedia package

If we want to stay in the beamer universe, the package multimedia comes as part of beamer (nevertheless you have to explicitly load it with \usepackage{multimedia}).

  • information can be found in the beameruserguide, section 14.1.1 Including External Animation Files

  • usage:

    The basic command to include a video/audio file is \movie[⟨options⟩]{⟨poster text⟩}{⟨movie filename⟩}, a short MWE can look as the following:

    \documentclass{beamer}
    \usepackage{multimedia}
    
    \begin{document}
    
    \begin{frame}
    \movie[width=8cm,height=4.5cm]{test}{eso50supernova.mov}
    \end{frame} 
    
    \end{document}
    

    This will include a movie of the type .mov with the specified size. test is the text that will appear on the slide and which, if clicked on, will play the video. There are many possible options, such as using an external viewer, automatically start the video or display an image as preview, please consult the documentation to read more about them.

  • file types:

    • mac: .mov,...
    • linux: '.mov', '.flv', '.mp4'
    • with external viewer option: everything your external viewer can
  • important note: The video file will not be embedded in .pdf file, if you want to present the pdf from another computer you also have to copy the movie file.

  • viewer:

    • mac: adobe reader (you may have to tell adobe reader to trust this .pdf)

    • linux: okular (at least under ubuntu 18.04 LTS)

    • not working: preview (mac), skim (mac), TeXStudio internal viewer (mac)


pdfpc pdf viewer optionally with pdfpc-commands

pdfpc targets presentations in pdf format regardless of the producer of that presentation. It also supports showing notes on another screen (see this answer), which integrates nicely with the way of adding notes in beamer.

  • information can be found on the pdfpc homepage and on their github repository.

  • usage In their example with movies they provide an example:

    \documentclass{beamer}
    
    \setbeamertemplate{navigation symbols}{} % don't use navigation tools on slides
    
    % use our .sty file for simple movie commands
    \usepackage{pdfpc-commands}
    
    
    \begin{document}
    
    % Full frame movie exmaple
    \frame{
        \frametitle{Example}
    
        Open with: \texttt{pdfpc video-example.pdf}
    
        \vspace{25pt}
    
        A full frame video using \textbf{commands from \texttt{pdfpc-commands}} is on the next slide.
    }
    
    \fullFrameMovie[loop]{apollo17.avi}{apollo17.jpg}{\copyrightText{Apollo 17, NASA}}
    
    % Inline movie example
    \frame{
        \frametitle{Example 2}
    
        A video using the \textbf{commands from \texttt{pdfpc-commands}} is on this slide.  The video is set to start at 5 seconds and end at 12 seconds.
    
        \vspace{20pt}
    
        \inlineMovie[loop&autostart&start=5&stop=12]{apollo17.avi}{apollo17.jpg}{height=0.7\textheight}
    }
    
    % Inline movie example
    \frame{
        \frametitle{Example 3}
    
        A video using the \textbf{basic syntax} is on this slide.  The video is set to start at 5 seconds and end at 12 seconds.
    
        \vspace{20pt}
    
        \href{run:apollo17.avi?autostart&loop&start=5&stop=12}{\includegraphics[height=0.7\textheight]{apollo17.jpg}}
    }
    
    \frame{
        \frametitle{Image example}
    
        An example full frame \textbf{image} is on the next slide.
    
    }
    
    % Full frame iamge example
    \fullFrameImage{a17_moon.jpg}{\copyrightText{Apollo 17, NASA}}
    
    
    
    
    \end{document}
    

    The .sty file pdfpc-commands can be found in the example.

  • file types

    • those supported by gst-plugins-good and gst-libav for example mp4 and avi
    • gif not working
  • important note: The video file will not be embedded in .pdf file, if you want to present the pdf from another computer you also have to copy the movie file.

  • viewer: pdfpc is the viewer available in binary on some linux distros and source for mac and windows. Embedded videos will not play in other pdf viewers (tested with envince and TeXStudio internal viewer (linux)).