92

I sometimes have to present on other people's equipment, such as machines running stripped down Linux distributions, presentation servers with a bare-bones PDF viewer running in a virtual machine, or a Windows box with a heavily locked-down Adobe Reader (e.g. with JavaScript disabled). So far I've tried to avoid doing anything fancy with beamer. But for some concepts, animations seem necessary.

How can one create PDF presentations in LaTeX, preferably with beamer, which include animations that work on most PDF viewers?

Ideally, if the animations don't work then they should degrade gracefully. For instance, the first and last frame could still be shown.

Beamer has \animate but this requires the PDF viewer to support showing several slides in succession, without manual intervention. Jens Nöckel suggests using external movies, which seems even less likely to work; this relies on a viewer being available for the movie format, and that the movie viewer can be called by the PDF viewer.

Older documents suggest MetaPost or animated GIF files, which seem hacky (though I will consider them if no other alternatives exist).

Please discuss only one main approach per answer.

lockstep
  • 250,273
András Salamon
  • 2,145
  • 3
  • 25
  • 33

4 Answers4

40

As discussed in https://stackoverflow.com/questions/2428372/insert-video-clip-in-a-lyx-presentation-and-play-it-in-gnu-linux, you can use the multimedia package to embed movies (mpg, mp4) in a way that you can play them in Okular. Minimal example:

\documentclass{article}
\usepackage{multimedia}
\begin{document}
\movie[height = 0.6 \textwidth,width = 1.0 \textwidth]{}{animation.mpg}
\end{document}
Turion
  • 4,622
  • 2
    +1! the only solution that worked with me so far! thanks! – smihael Jan 27 '13 at 14:42
  • 2
    Good answer. This works with Okular but sadly not with impressive:( – Gabriel Feb 07 '13 at 00:08
  • That's probably because impressive still relies on the antique Xpdf. Maybe you can ask the developer team to write a backend for the more advanced Poppler and they might be able to implement movie embedding easily. – Turion Feb 08 '13 at 17:43
  • With TeX Live 2015 and Okular Version 0.24.2 this solution does not work. There are no compilation errors, but Okular only displays a blank space. – Luís de Sousa Mar 24 '17 at 13:22
  • @LuisdeSousa, both are outdated. It should work with up to date TeX Live and Okular. – Turion Mar 24 '17 at 14:14
17

The movie15 package allows you to set graphics or text, including the first frame of the movie, to display if the movie is inactive. This can be achieved with the text and poster options (taken directly from the documentation):

\includemovie[
  text={\includegraphics[scale=2]{path/to/poster}}
]{}{}{path/to/movie}

will display the image specified by path/to/poster, scaled to twice its size, and

\includemovie[
  poster,
  text={\phantom{\includegraphics[scale=2]{path/to/poster}}}
]{}{}{path/to/movie}

will display the first frame of the movie, and make it the size of the scaled path/to/poster.

This obviously doesn't make the included movie playable in any more locations than it otherwise would be, but it does make it more elegant when playback is unavailable.

Michael Underwood
  • 21,356
  • 13
  • 52
  • 41
12

The easiest way to produce animations from image sequences (pdf, mps [metapost], jpeg, png, jb2 with pdflatex; ps/eps, mps with latex) or inline images (pstricks, tikz) is to use the animate package. Depending on the option settings, poster=first or poster=last, bare-bone viewers without JavaScript, such as Xpdf, GV or GSview will display the corresponding animation frame. For playback, however, Adobe Reader is indispensable. Animated Gif must be split into png or eps sequence before embedding, because it is not supported by the PDF specification.

http://www.ctan.org/tex-archive/macros/latex/contrib/animate/animate.pdf

AlexG
  • 54,894
9

This is a somewhat different approach to rendering animations or movies in Linux Latex Beamer presentations:

  • Firstly I use Kazam to convert any animations into more compressed mp4
  • Secondly, I use \href{run:./directory/file.mp4}{MOVIE} in Latex/Lyx to generate the link within a pdf file.
  • Thirdly I use mpv as a media player.

Its config file in /etc/mpv/mpv.conf has just the one line: use-filedir-conf. Then, one can set in the beamer presentation directory a file called mpv.conf with lines such as this:

screen=1
geometry=60%+380+80
  • The screen=1 allows the file.mp4 to played on the extended desktop such as the projector.
  • The geometry= line allows one to set the magnification and the position of the window in which the movie will be rendered.

More details can be found in the mpv manual.

Finally, I use Impressive to render the pdf. Altogether a very pleasant way of saying goodbye to acroread and Adobe.

pluton
  • 16,421