[Tex/LaTex] Embedding videos using media9

media9

I'm really new to LaTeX and I'm not very good with computers. I'm trying to put videos into my PDF's. I'm using media9 and I've got the following going so far.

\usepackage{media9} 

 \includemedia[
    width=0.6\linewidth,
    height=0.45\linewidth,
    addresource=/Users/tristanjohnson/Library/texmf/tex/latex/misc/media9/Ruinn.MP4,
    activate=onclick,
    deactivate=onclick,
  ]{Movie}{Ruinn.MP4}

\mediabutton[ mediacommand=some_dice:playPause, overface=\color{blue}{\fbox{\strut Play/Pause}}, downface=\color{red}{\fbox{\strut Play/Pause}}
]{\fbox{\strut Play/Pause}} \mediabutton[
mediacommand=some_dice:setSource [(random.mp4)] ]{\fbox{\strut random.mp4}} \mediabutton[
mediacommand=some_dice:setSource [(cube.mp4)] ]{\fbox{\strut cube.mp4}}

I merely copied and pasted the mediabutton stuff. When I hit "Typeset" it runs without any errors. But when I click the play button nothing happens. I want the video embedded in the PDF so other people can see the video without having to have the file locally. Help?

Best Answer

Media files to be played back are usually embedded into the PDF (although playing files from remote URLs via http and rtmp protocols is supported too).

Media9 implements playback of media files inside PDF documents using the FlashPlayer plugin in Adobe Reader. This feature is currently available on the Windows and OSX platforms.

Two prerequisites are necessary: The media file (a video in the MP4/H.264 or FLV formats) and a media player in the Flash format (e. g. VPlayer.swf provided by Media9).

The latter is embedded by setting it as the last argument of \includemedia, while option addresource=... instructs LaTeX to physically embed a video file into the PDF.

Furthermore, VPlayer.swf needs to be told what to play. Flash applications are configured via FlashVars. For this, \includemedia provides the flashvars option. The most important FlashVar of VPlayer.swf is source=... which sets the media source. More FlashVars exist, e. g. for setting the sound volume, or loop which tells VPlayer.swf to infinitely replay the video. Refer to the Media9 documentation for other configuration options.

It is a good idea to place media files for embedding into the directory of the document you are about to write, or into a sub-directory of it. Lets assume Ruinn.MP4 is in the subdirectory videos. A minimal working example would read:

\documentclass{article}
\usepackage{media9}

\begin{document}

\includemedia[
  width=0.4\linewidth,
  height=0.3\linewidth,
  activate=pageopen,
  addresource=videos/Ruinn.MP4,
  flashvars={source=videos/Ruinn.MP4}
]{}{VPlayer.swf}

\end{document}

Note that the paths to the video file used with the addresource option and with the source FlashVar must be identical. Further note, that MP4 is only a container file format for video. The video data inside the file must be encoded with the H.264 codec. Another option is the FLV file format.