[Tex/LaTex] media9: artefacts in embedded movie and looping inconsistent

beamermedia9

I'm really having trouble to play back movies consistently, and I'm not sure where my workflow fails.

Usually desired behavior:

  • one slide with a still of the first movie frame. I would tell the audience what to expect.
  • movie starts playing after I click with my presenter and then loops until I go to the next slide

To achieve this, I manually take a snapshot of the first frame, and put it on one slide, then build the very same slide again, but with the movie instead of the snapshot and the option autoplay = true. I know it's not pretty, but I was not able to get movies to start consistently on mouseclick and with this workflow I get the desired behavior most of the time.

Nevertheless, I continue to have trouble with looping the movies. Sometimes, the movie just won't loop but stop after one run. Sometimes, the movie will loop, but there will be heavy artifacts from the second run on. Compiling the same document multiple times will produce different behavior. This is really a dealbreaker, because I cannot even rely on the fact that a movie that I got working will continue to work, I have to check every single movie after each compile which is of course very tiring.

I'm seeing the same issues with a number of different movies, not just with this one. Most common artifact is for the movie to turn into a green hue, but I have also seen pink, red and yellow stripes – or sometimes red lettering spelling the filenames of the included .tex files – which I doubt is coming from the movie itself, but looks more like a pdftex issue.

Source code, pdf, movie files and screenshot of the artifacts here:
https://cloud.mpi-cbg.de/index.php/s/wqZ2Xx3kmI17XZZ
When I play the pdf on my system, it loops but has artifacts in the 2nd run.

The example movie was downloaded from here: https://www.youtube.com/watch?v=ytqJjpdsNi8
then converted to h.264 using the "Handbrake" tool (I think it's essentially a GUI frontend for the ffmpeg codecs)

  • Mac OS X 10.11.6
  • TeX Live 2016
  • media9 0.76
  • Adobe Reader 15.23.20056.213124 (I know it's oldish, but every time I update Adobe Reader, something else in the videos breaks)

Conference talk is on Monday, so any help is highly appreciated …

\documentclass[usenames,dvipsnames]{beamer}

\usepackage[english]{babel} % English spell check
\usepackage[utf8x]{inputenc} % utf8 support, also \usepackage[utf8x]{inputenc}
\usepackage{graphicx} % for graphics, subfigures etc., option pdftex is needed for incorporation of .pdf files
\usepackage{media9}
\usepackage{tikz}

\beamertemplatenavigationsymbolsempty % Turn off navigation bar at the bottom

\mode<presentation>{
    \usetheme{Warsaw}   
    \usecolortheme{seagull}
}

\begin{document}
\begin{frame}{Optical projection tomography on fixed samples}\begin{center}
        \vspace*{-1mm}\includegraphics[width=12cm, height=8.2cm]{Mouse.png}
\end{center}\end{frame}
\addtocounter{framenumber}{-1}
\begin{frame}{Optical projection tomography on fixed samples}\begin{center}
    \vspace*{-1mm}\includemedia[activate=pageopen,deactivate=pageclose,width=12cm, height=8.2cm,addresource=Mouse.mp4,
    flashvars={src=Mouse.mp4 &playbutton=none &loop=true &autoPlay=true}]{\includegraphics{Mouse.png}}{StrobeMediaPlayback.swf}
\end{center}\end{frame}
\end{document}

Best Answer

playbutton is not a Flash variable of the player (Strobe) but an option to \includemedia.

The code produces a document in "presenter mode", as requested in the OP, for situations without access to a mouse. The still image is on the slide before the video. The video is loaded and auto-started when passing to the slide containing it. The example uses plain VPlayer.swf instead of Strobe.

If a mouse is accessible, playback can be controlled as follows: Press the mouse button over the running video in order to pause it. Give further explanations to the audience, if desired. Release mouse button to continue playback.


The handbrake (odd name for a media encoder, btw) encoded video does not loop well. This could be fixed by re-encoding it using ffmpeg:

ffmpeg -i Mouse.mp4 -vf scale="trunc(iw/2)*2:trunc(ih/2)*2" -c:a copy -c:v libx264 -profile:v high -pix_fmt yuv420p -g 30 -r 30 Mouse1.mp4

\documentclass[usenames,dvipsnames]{beamer}

\usepackage[english]{babel} % English spell check
\usepackage[utf8x]{inputenc} % utf8 support
%\usepackage{graphicx} % for graphics, subfigures etc., option pdftex is needed for incorporation of .pdf files
\usepackage{media9}
\usepackage{tikz}

\beamertemplatenavigationsymbolsempty % Turn off navigation bar at the bottom

\mode<presentation>{
  \usetheme{Warsaw}    
  \usecolortheme{seagull}
}

\begin{document}

\begin{frame}{Optical projection tomography on fixed samples}
  \begin{center}
  \only<1>{\includegraphics[width=0.8\linewidth]{Mouse.png}}
  \only<2>{\includemedia[
    width=0.8\linewidth,
    playbutton=none,
    activate=pageopen,
    addresource=Mouse1.mp4,
    passcontext, %enable right-click menu 
    flashvars={
      source=Mouse1.mp4&
      loop=true&
      autoPlay=true
    }
  ]{\includegraphics{Mouse.png}}{VPlayer9.swf}}
  \end{center}
\end{frame}

\end{document}