Some time ago I asked this question How to include a movie in a PDF? Step by step instructions. (I tried everything documented there, and links therein. I can't find the combination of tools to be able to playback embedded movies in a PDF viewer in Linux.)
This time I am going to be more direct: Was anyone, with a certain combination of tools and viewer, able to create a PDF from TeX with an embedded movie and play it back in a Linux viewer (for example some version of Acrobat)?
If, so what package, tex version, acrobat version was used?
EDIT 2014
Thanks to @AlexG, great advances have been made regarding the inclusion of movies and in particular the playback in Linux. It is just a pity that Acrobat for Linux is at its end of life (not so much for Adobe but because nobody is picking up the torch for embedded media).
This edit simply summarizes a working solution that is illustrated by defining a command \includemove[dimensions]{moviewithoutextension}
, that produces movies that can be played back in Acrobat 9.4.1 (Linux), Acrobat for Windows and Mac and that fallbacks to external players (and a still picture) in other PDF viewers.
Assumptions:
- You have a copy of jw-player 5.10 (
not 5.9 or 6.x
) in your local directory and it is namedplayer.swf
. (from here http://developer.longtailvideo.com/trac/browser/tags/mediaplayer-5.10, documentation here: http://www.longtailvideo.com/support/jw5/31138/configuration-options) - You have
ffmpeg
version 2.1.4. -
You have a copy of your movie in the
mp4
format. Any movie can be converted in this wayffmpeg -i $MYMOVIE.vid -vf scale="trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 -profile:v high -pix_fmt yuv420p -g 25 -r 25 $MYMOVIE.mp4
ffmpeg -i $MYMOVIE.vid -qscale 0 -vcodec libx264 -x264opts keyint=25 $MYMOVE.mp4
-
A preview image with the same name but extension
png
. This can be achieved by converting your movie in this way and taking an snapshot:ffmpeg -i $MYMOVIE.mp4 -ss 00:00:2.1 -f image2 -vframes 1 $MYMOVIE.png
-
[optional] A PDF image with the same name but
pdf
extension to replace the PNG preview in case Flash content is not active. -
You are OK using the packages
hyperref
(andmedia9
of course). -
[for playback] You have Acrobat 9.4.1 (for playback in Linux) or more modern versions in other systems.
- [for playback] For other PDF viewers: the extension
mp4
is associated with some application and the movie is distributed with the PDF.
Limitations (of my poor implementation, not of media9
)
- Only
width
and/orheight
can be specified as options. - No other player than
jw-player
can be used (options are hardcoded in the command definition). - It assumes a lot of defaults regarding the behavior of the embedded player.
- [For fallback] The definition tries it best to have a nice fallback mode for other viewers, and you have to choose (see the code) between embedding the movie or having an external file.
- [For playback] I don't know if it works in all viewers, it works at least in Acrobat 9.4.1 (Linux) and Evince 3.10.3 (Linux). I saw it work in Acrobat X in Windows and Mac after a "security message" confirmation.
Given this conditions, the following document that includes the definition of \includemovie
and summarizes a working solution.
\documentclass{article}
\usepackage[noplaybutton]{media9}
\usepackage[colorlinks]{hyperref}
\usepackage{attachfile2}
\newcommand{\includemovie}[2][]{
\includemedia[
#1,
activate=pageopen,transparent,
addresource=#2.mp4,addresource=#2.png,
flashvars={
file=#2.mp4&image=#2.png&
stretching=uniform&start=0&
screencolor=white& %improves render in light backgrounds
controlbar.position=over&controlbar.idlehide=true&
autostart=true&repeat=always&smoothing=true
%&bufferlength=10 % may improve repetition of short videos
}
]{ % for disabled content (in most cases this is fallback)
\begin{tabular}{ll}
\mbox{
% \href{run:#2.mp4} % for not embedded fallback
\textattachfile[color={0 0 0}]{#2.mp4} % for embedded fallback
{\texttt{|\kern-.23em>}} % poor play button
} & \raisebox{-\height}{\includegraphics[#1]{#2}}
\end{tabular}
}{player.swf}
}
\begin{document}
\includemovie[width=5cm]{MYMOVIE} %no extension!
\end{document}
(note: you may benefit by producing JPEG
snapshots, PNG
are usually very big, sometimes as big as the whole movie)
Best Answer
Update
As of 2013/11/04, package
media9
contains media player Flash componentsVPlayer9.swf
andAPlayer9.swf
. They are compatible with the (somewhat outdated) Flash Player 9 plugin that is bundled with Adobe Reader for Linux 9.4.1 and can be used for producing PDF documents with embedded video (MP4/H.264) and audio (MP3) which target this particular Linux version of Adobe Reader.Alternatively, any Flash-based media player found on the Web which is Flash-9 compatible and which can be configured via FlashVars could be used. (Though the number of such players should be decreasing with the advent of newer Flash versions.)
NB: Flash and media playback was dropped in more recent Readers. AR-9.4.1 is the last version on Linux which supports Flash.
Adobe Reader 9.4.1 for Linux can be downloaded from ftp://ftp.adobe.com/pub/adobe/reader/unix/9.x/9.4.1/.
Example code using
cube.mp4
andVPlayer9.swf
from themedia9
package: