[Tex/LaTex] How to embed a mpg video in Beamer presentation using `media9`

beamermedia9movie15multimedia

I just read the documentation for media9 but was not able to identify what I am doing wrong. The videos in the documentation all play fine in my installation of Adobe Acrobat Pro. When I compile the example below, the slide has a box for the video that says "(click to play)" but when I click, all I see is white.

\documentclass{beamer}

\usepackage{media9}

\begin{document}

\begin{frame}{}
  \includemedia[width=0.6\textwidth,height=0.45\textwidth]{(click to play)}{4x167_h5_k010.mpg}
\end{frame}

\end{document}

Here is a link to the mpg file I am including. I am actually not sure the aspect ratio of the video. In addition to even showing up and playing, I am also interested to know the following

  1. Do I have to specify both the width and height? I would rather specify the width and that it maintain the same aspect ratio.
  2. How do I get it to loop (I saw info in the documentation about this, just wanted to get it the play first)?

(I also tried the movie15 package and that gives a box that is all black)

Best Answer

Thanks to @AlexG for directing me to his solution for a closely related question. On closer review, there is no option to include mpg videos in movie15. This functionality has been deprecated together with media9. The newer package only accepts the more compressed, mp4 format.

I used ffmpeg to convert my mpg file to an mp4 file with the command:

ffmpeg -i 4x167_h5_k010.mpg 4x167_h5_k010.mp4

As a note, ffmpeg would not do the conversion until I had a standard aspect ratio. I had created the video using the Movie Maker extension of VMD. To obtain a 3x4 aspect ratio, I used the command display resize 1280 960, then regenerated the mpg video file.

Here is the final working example (with the video loop command):

\documentclass{beamer}

\usepackage{media9}

\begin{document}

\begin{frame}{}
  \includemedia[
    width=0.8\linewidth,
    height=0.6\linewidth,
    activate=pageopen,  
    addresource=4x167_h5_k010.mp4,
    flashvars={
      source=4x167_h5_k010.mp4
      &loop=true  % loop the video
    }
  ]{}{VPlayer.swf}
\end{frame}

\end{document}