51

A quick survey of the unanswered questions suggestions that about 20% of them are about problems with including multimedia files, such as videos or sound files. Many of them are about either using the wrong method for their file type (or the wrong file kind for their method) or use an unsuitable pdf viewer. Maybe this question can help to organise the information a bit.

There are different ways to include multimedia files in , which one work and which ones do not highly depends on the pdf viewer you use and the operating system you are on.

This questions tries to summarize the main information about the different packages which can be used, one answer per package.

Packages covered in this Q&A:

Tools/Viewers covered in this Q&A:

Useful Q&As on this site:

0

5 Answers 5

28

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
9
  • 1
    @Dr.Beeblebrox Thanks for fixing this mistake! So long and thanks for all the fish! May 31, 2017 at 20:50
  • For PDF-Xchange editor, I always get a warning To view the Flash content in this PDF file, please install the required version of Flash player. However, I am 100% sure that the flash is installed and working properly on all my browsers.
    – Diaa
    Sep 3, 2017 at 16:50
  • @sam : I think the YT example should be removed as it does not work anymore (YT stopped their Flash based player.).
    – AlexG
    Mar 3, 2018 at 9:56
  • @AlexG Do you know if there is some other example one could show instead? Or simply remove without replacement? Mar 3, 2018 at 13:40
  • 2
    Flash plugin will not be supported by Adobe after 2020
    – Rubi Shnol
    Jul 10, 2020 at 9:47
25

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, and all currently maintained Debian versions), pdfpc (tested for version v4.5.1pre within Debian 11)

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

3
  • 3
    It seems that this solution does not work for mp4 on Windows. Acrobat reader returns "name.mp4 is not a supported file type"... But avi seems to be fine.
    – Pygmalion
    Jul 16, 2017 at 18:02
  • 1
    It also doesn't seem to support mp4 file on mac either, although the Acrobat website seems to suggest it does - just my experience
    – Bamboo
    Feb 1, 2019 at 0:45
  • @Phill It might depend on the encoding of the mp4 file Feb 1, 2019 at 9:25
9

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)).

2
  • I'm unable to get my mp4 video to play, but I can get the example video to work. Is there some size limit or something?
    – fbence
    May 30, 2019 at 11:33
  • Note that pdfpc also plays videos in pdf files generated by pdflatex with beamer's multimedia package.
    – Joce
    Nov 12, 2021 at 15:56
4

pympress pdf viewer optionally with either vlc or gstreamer support

pympress targets presentations in pdf format regardless of the tool used to produce 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 pympress homepage and github repository.

  • usage: Pympress works best with the multimedia package. This means multimedia (gif, sound, video) included in this way will work in pympress as they will in other PDF readers that support them.

    • caveat: some options (e.g. autostart) are not currently supported.
    • Support for embedded files as well as multimedia files that are distributed alongside the PDF.
  • file types

    • gif support out of the box.
    • Video support via Gstreamer integration (file types require the appropriate Gstreamer codec packages, e.g. gst-plugins-good for mp4, gst-libav for avi, etc.)
    • Additionally, all video formats supported using VLC integration (requiring VLC as a dependency).
1
  • 1
    This is great work, thanks a lot! It would be great to include the minimal beamer example from the issue tracker in the pympress documentation.
    – Clément
    Feb 27, 2021 at 5:31
1

Following is a wrapper for these commands (described in one of the above answers) to ease the multiple uses. It is demonstrated for media9 package. However, it can be used with any of the above packages.

Define a new command in the preamble-

\newcommand{\includemovie}[3]{%
    \includemedia[%
    width=#1,height=#2,%
    activate=pagevisible,%
    deactivate=pageclose,%
    addresource=#3,%
    flashvars={%
        src=#3 % same path as in addresource!
        &autoPlay=true % default: false; if =true, automatically starts playback after activation (see option ‘activation)’
        %&loop=true % if loop=true, media is played in a loop
        %&controlBarAutoHideTimeout=0 %  time span before auto-hide
    }%
    ]{\fbox{Click!}}{StrobeMediaPlayback.swf}%
}% end of the new command

Later, use this command to insert a video as follows --

\begin{frame}{multimedia}
\begin{center}%
    \includemovie{\linewidth}{.6\linewidth}{video.flv}%
\end{center}%

Note from personal experience: with media9, use .flv format rather than .mp4; as not all codecs of mp4 format are supported.

4
  • 3
    Can you please -- as usual here -- make your code snippet compilable?
    – Mensch
    Mar 29, 2019 at 19:14
  • 1
    Isn't this just a wrapper around the command described in the accepted answer?
    – TeXnician
    Apr 6, 2019 at 11:07
  • @TeXnician yes, the answer is based on command described in the above answer, but I think it simplifies the use greatly. Therefore I think, the reader would appreciate this answer too. Apr 8, 2019 at 17:39
  • 1
    I don't think your command will work in any of the other packages except media9 without significant issues and since it adds additional layers of complexity may raise many more questions than answers
    – user170109
    Apr 9, 2019 at 2:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .