93

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.

14
  • 7
    Out of curiosity: what PDF viewers except Adobe Reader are able to show animated GIFs or MetaPost? I might be mistaken but as far as I know, the answer is “none”, and your quest is hopeless. Commented Jul 28, 2010 at 8:19
  • 1
    What happened to the old answers to this question? Commented Jul 28, 2010 at 8:28
  • 1
    @Will Robertson: There have been some database errors, I'm afraid :( Commented Jul 28, 2010 at 14:59
  • 2
    @András: movie15 requires not only Adobe Reader, but also an external media player and Windows. Package animate only needs Adobe Reader.
    – AlexG
    Commented Apr 8, 2011 at 12:19
  • 1
    @Kevin, what other formats can TeX output to that support animations?
    – Turion
    Commented Mar 29, 2012 at 16:37

4 Answers 4

41

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}
5
  • 2
    +1! the only solution that worked with me so far! thanks!
    – smihael
    Commented Jan 27, 2013 at 14:42
  • 2
    Good answer. This works with Okular but sadly not with impressive:(
    – Gabriel
    Commented Feb 7, 2013 at 0: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
    Commented Feb 8, 2013 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. Commented Mar 24, 2017 at 13:22
  • @LuisdeSousa, both are outdated. It should work with up to date TeX Live and Okular.
    – Turion
    Commented Mar 24, 2017 at 14:14
18

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.

1
  • 9
    Quick comment that movie15 has been superseded by media9, after this answer was posted.
    – 0 _
    Commented Aug 8, 2013 at 6:56
13

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

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.

You must log in to answer this question.

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