Playing embedded movies in LaTeX PDF

Things have changed since I first posted this (find a summary here): the Okular version shipped with KDE 4.2/SuSE Factory plays embedded movies (haven't checked projector output yet, but for that, the graphics driver is responsible anyhow). There seems to be some unreliability in showing poster images, still, and phonon refused audio playback, but the basic functionality is there. For Lilypond users: point-and-click annotations also work by now. KDE users, consider the following post to be slightly historic ;-).

This is a really tough one - I fiddle with it every few months and ruefully come back to the mplayer workaround afterwards.
Let's suppose you want to create a LaTeX/Beamer presentation with embedded video:
a) Adobe Reader 8 for linux is indeed capable of embedding a multimedia player, but apparently only the proprietary Real Player.
b) Real Player/Helix for Linux still refuses to play any .avi-contained movies.
c) Format and specification collisions are all over the place - see this discussion.
Adobe passing the blame to Real passing the blame to the LaTeX developers and back again isn't exactly helpful either.

Possible solutions:
a) Get the Real Producer for Linux and try encoding your stuff as Real Media. RealPlayer also claims to play OGG video.
The beamer package seems to use rather dated PDF specifications and can't embed RealMedia. However, you can embed multimedia in beamer presentations via movie15, which is supposed to be more up-to-date.
My tests:
I converted an avi movie to OGG .ogv with ffmpeg2theora (available from packman), which the standalone RealPlayer refused to play outright and movie15 didn't want to embed.
I tried to encode a movie with Real Producer, which is a real pain, if I remember right: only uncompressed input movies accepted, and in the end the movie consisted of an audio track only.
A Real Media test movie can be found on the Penn State site.
I embedded that one in a minimal example:
Acroread didn't complain about anything, but didn't play the video either.
Somebody reported success by editing the PDF in Acrobat, which seems to run so-so on wine.
And it sucks to have to convert your movies to an player-restricted closed-source format to embed them in Linux :-(

b) Wine. Gee, I don't even remotely want to try this. According to the
Wine AppDB, Adobe Reader and e.g. Windows Media Player might work separately - I haven't seen anything about embedding. Here at least you have some choices concerning format and player.

c) VMWare: Thanks, I already have a Windows dual-boot.

d) Wait for Okular. According to bugs.kde.org something is brewing there, but I suppose it won't be released for the next few months. No embedding in KPDF is planned because of the upcoming Okular feature. Update: Okular works (more or less) by now.

e) There is some kind of workaround by externally linking to MPlayer:
\href{run:<some code>}, the code can be a shell script or a direct bash command (cf. this thread for details). The geometry option in MPlayer should take care of the screen placement. In any case, you will still have window borders (maybe choose a borderless desktop style?)
P.S.: It's cumbersome, but it works (no borders and all - posted it).


marius said...

this is a tough problem.
anyhow, I tried externalviewer option for \includemovie: this creates a clippy attachment -- if you click it, it opens in default external player (totem in my case).
I really dislike realplayer -- it is useless on my system (does not play *any* format producable by ffmpeg at all).

Perhaps there are docs explaining the embedding API/protocol, then we could just replace realplay binary with whatever we want.

avocadohead said...

Yep. Regarding the external viewer option - in that case I'd prefer the MPlayer workaround, where you have at least control over movie size and positioning. You can actually simulate embedding (as posted...)

I don't think either the helix/real stuff does any good at the moment as long as it doesn't play mpeg/avi. Furthermore, the LaTeX packages seem to be 'overcompatible' with outdated PDF specifications - it's a marvel it works on Windows at all ;-)

Considering embedding/API specs - the Adobe Reader is pretty much closed source, and on KPDF etc. there is nothing in sight (security reasons?)
However, the Adobe guys invite everybody on their forum to contribute to the development - I'm a beyond lousy programmer with no free time, but anyone else feel free to join them ;-)

Marius said...

Well, you also have control over standalone media player (just one keystroke and you can resize the window to 1:1 or 1:2 scale with totem). And mplayer workaround is quite complicated.

It's true that Acrobat is closed, but the API does not seem so, there is SDK, I don't know whether it also works for Linux, but it is probably much better to focus the same effort for open source viewers. In particular I like keyjnote for presentations. So Acrobat seems to be doomed in Linux.

Marius said...

OK, here is the root cause on why Acrobat is left out in Linux:
the latest SDK for linux is only version 7.0 (where people say that movie embedding worked fine there), and there is nothing for 8 and 9.