02/03/2012

Movie playback in Latex/Beamer: the current situation with Adobe Reader, Okular and Impress

A few years ago, the only option to include multimedia content in Linux presentations was linking to an external player. While the situation is still far from ideal, we have a few options now:
  • Okular has been able to play back movies via mplayer for quite some time now. Features: pause and seek. Downside: poster images appear all black (fixed in KDE 4.10), control bar spacing.
  • Adobe Reader can embed external flash players and videos. Features: pause. Downside: Flash, works only with old acroread.
  • Open/Libre Office Impress movie playback finally works. Features: presenter console. Downside: plays immediately, pause and seek only outside presentation mode. Also, the LaTeX PDF has to be converted into page images.
I used the following encoder configurations (from series of PNGs, framerate 12):
mencoder mf://*.png -mf fps=12:type=png -ovc x264 -x264encopts bitrate=5000:threads=2 -o movie.avi
mencoder mf://*.png -fps 12 -nosound -forceidx -of lavf -ovc lavc -lavcopts vcodec=flv:vbitrate=4000:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -o movie.flv
Adobe Reader with control bar

Flash/Adobe Reader HowTo (taken from projects.nuschkys.net):
This requires Adobe Reader X with 9.0 < X < 9.4-2, which is a problem as that version isn't packaged from Natty upwards. I managed to install the Maverick 9.4-1 version on Natty, but there's no guarantee it will continue working on newer distributions. Download the player plugin (player.swf) and flashmovie.sty to the same directory as your .tex file. LaTeX code (pdflatex, replace file names in brackets appropriately):
\usepackage{multimedia}

\flashmovie[controlbar=0,image=<posterimage.png>, engine=jw-player,width=<width>, height=<height>]{movie.flv}
With controlbar=1, you can activate a control bar, but it doesn't do anything for me except looking ugly on my screen. However, pause and play on click also work without visible controls.
Okular with control bar

Okular HowTo (with Mplayer plugin):
The main problem with this solution is the black poster image in Okular for KDE < 4.10, so if you can, upgrade. Also, using a movie still as poster image to set your movie dimensions doesn't work if you keep the (working!) movie control bar visible - you have to add space for the control bar at the bottom. LaTeX code:

\RequirePackage{flashmovie}
\usepackage{multimedia}

\movie[loop,autostart,poster,showcontrols=true]{\includegraphics[width=<width>, height=<scaledheight>]{<posterimage.png>}}{movie.avi}}
If you want to show controls, adjust 'scaledheight' until there are no black margins while the movie plays (I didn't manage that completely), but I suspect the scaling changes with the screen/projector resolution.
Impress presenter console and presentation on separate screens.

Impress HowTo (python conversion script):
The reason to use Impress is its wonderful keynote-inspired presenter console (libreoffice-presenter-console/openoffice.org-presenter-console). The downside is that movies play on autostart and end with a black frame in presentation mode and there seems to be no way yet to change that. Movies look wonky on previews (see image), but play well on the presentation screen. LaTeX code:


\pdfminorversion=4
\documentclass[svgnames]{beamer}
...

\usepackage{multimedia}


\only<1>{\includegraphics[width=<width>]{<posterimage.png>}}
\only<2>{\movie{\includegraphics[width=<width>]{<posterimage.png>}}{movie.avi}}}
\only<3>{\includegraphics[width=<width>]{<lastimage.png>}}
I simulated play on click by adding a separate slide with the poster image before the movie, another with the final frame after the movie (see \only blocks in LaTeX code) and having the slide change automatically after the movie has finished. The python conversion script (requires odfpy and mplayer) extracts page images from pdf files, reads movie paths and coordinates from the pdf and determines the movie duration (no subseconds precision) with mplayer. Optionally,presentation notes can be added from a separate text file (see image, individual notes separated by '#' in text).
Usage:
python pdf2odp.py <presentation.pdf> -n <notes.txt>
python pdf2odf.py -h #help
Output:
<presentation.odp>. Page images are embedded, movies are linked, so if you didn't specify absolute paths in LaTeX, take care where you put your movies.
Note: Specs changed considerably between PDF versions 1.4 and 1.5, which means that my movie identification script doesn't work with texlive2012's standard PDF output. You can set a specific PDF version e.g. by explicitly setting the minor version to 4 (see example above).

3 comments:

Andy said...

One other option for the Flash version is to install acroread directly from adobe, using their installer. This worked using version 9.4.1 i486 on my Lucid 10.04 x64 system. The file I downloaded was AdbeRdr9.4.1-1_i486linux_enu.bin from here: ftp://ftp.adobe.com/pub/adobe/reader/unix/9.x/9.4.1/enu/

Less direct link: http://www.adobe.com/support/downloads/product.jsp?product=10&platform=Unix


Thanks for a great post.


- Andy

Arno said...

Thanks. Finally I can have movies in my presentations without using the much hated Acrobat Reader.

Autoplay doesn't really work though. But that's only a minor nuisance. Now if only they could resolve the black window issue. But maybe there's a work around. If I find one I'll let you know.

avocadohead said...

@Arno: looks like KDE 4.10 will solve it for you ;)