# Strange behavior with external library of Tikz and media9 package

When using external library of Tikz and includemedia of media9 package in a beamer presentation, PDF files generated by external library has an abnormal size. In the simple example below, when compile without including the video, PDF standalone files for tikz figure are very small (about 1ko) but when compile with the video, PDF files are much bigger (5.5 Mo !! for the second figure). My presentation uses a lot of tikz figures (more than 100 !) and some videos (about 40 Mo each). When I compile it (MacTex 2015 / Tekmaker) more than 4Go of PDF files are generated !!! I tried to deactivate externalize with \tikzexternaldisable .... \tikzexternalenable but it has no effect ...

How can I solve this .... Thank's for Help.

\documentclass[aspectratio=43,8pt]{beamer}
\usepackage{media9,tikz,graphicx}
\usetikzlibrary{external}

\tikzexternalize
\tikzsetexternalprefix{./tikz-fig/}

\begin{document}

\begin{frame}
Example of tikz figure :
\begin{figure}
\begin{tikzpicture}
\draw [black,fill=red!10,very thick](0,0) rectangle (5,5);
\draw [black,fill=blue!10,very thick] (3,2) circle(1);
\end{tikzpicture}
\end{figure}
\end{frame}

\begin{frame}
Example of video :

\begin{center}
\includemedia
[
playbutton=plain,
activate=onclick,
flashvars={source=big_buck_bunny.mp4}
]
{\includegraphics[width=0.5\textwidth]{poster.png}}{VPlayer.swf}
\end{center}
\end{frame}

\begin{frame}
Example of tikz figure :
\begin{figure}
\begin{tikzpicture}
\draw [black,fill=red!10,very thick](0,0) rectangle (5,5);
\draw [black,fill=blue!10,very thick] (4,4) circle(1);
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}

• The playbutton in media9 is made with TikZ. Maybe the reason? Try playbutton=none to see whether it makes a difference. – AlexG Sep 13 '15 at 7:33
• Thanks AlexG for this suggestions ....After testing your idea nothing change ... also test to set "optimize=true" in externalize options, specify \pdfminorversion=5, \pdfcompresslevel=9, \pdfobjcompresslevel=2, update my media9 package with the last version, ... the problem is still here. For the moment I compile my beamer lecture in two steps, first without video and seccond with video. – Pascal LAFON Sep 13 '15 at 15:57
• I looked into the generated image pdfs. They all contain the media files (*.mp4 and VPlayer.swfof the second slide. – AlexG Sep 14 '15 at 8:30
• Thank you AlexG. That confirm my intuition. Maybe a interaction between tikz externalize macro and media0 package, in the management of variables during the compilation. My knowledge of internal mechanism in LaTeX compilation are not sufficient to go further ... – Pascal LAFON Sep 15 '15 at 10:49
• Fortunately, the final PDF is ok. Don't know why the externalise library inserts unused code into the standalone image files. – AlexG Sep 15 '15 at 11:26