42

Media9 is becoming obsolete Dec 2020 due to Adobe dropping Flash support. Is there any replacement out there that does not rely on Flash that will allow the inclusion of video and audio in latex documents?

3
  • 1
    The package is still under active development (last commit just a week ago, see gitlab.com/agrahn/media9/commits/master) so this may be fixed by the maintainer. You can open an issue on Gitlab if you want to ask about this directly.
    – Marijn
    Nov 11, 2019 at 21:35
  • 3
    Thanks for the notice. Do you know of any official statement by Adobe on his regard? Especially in connection with embedded media support in PDF?
    – AlexG
    Nov 12, 2019 at 7:10
  • Just to let everyone know: The old, allegedly obsolete movie15 package seems to work still fine for playing movies, at least when using Adobe Reader. (I checked it only for a few mp4 movies and only on macos...) Jan 26 at 14:37

3 Answers 3

35
+100

Official Adobe documents on embedded multimedia support (MP4/h.264 video, MP3 audio) in PDF, such as https://helpx.adobe.com/acrobat/using/adding-multimedia-pdfs.html, are still Flash-centric. Thus, it seems Adobe have not yet decided on the future of multimedia in PDF beyond Flash EOL. Maybe, they are working on it, but nothing has been disclosed to the public yet.

Update 04/2021

Here is a minimal Flash-free implementation of video embedding, which is very similar to the one Adobe themselves currently have to offer to their users of Acrobat.

With the help of users J. Hagemann, D. Savransky, M. Vlasák and others in the bug tracker, an acceptable solution could be put together for Acrobat Reader, that allows the user to control playback through the controls of the OS specific media player plug-in. For video that also plays in the Okular PDF viewer, try the method suggested by user Fritz.

To get it working on Windows, the following tweak of the Registry is necessary. Unfortunately, it must be done with Administration privileges, running (clicking in the file explorer) the following file (information found by user Deepblue):

File enablePlayerControls.reg:

REGEDIT4

[HKEY_LOCAL_MACHINE\Software\Wow6432Node\Adobe\Acrobat Reader\DC\FeatureState]
"HonorControls"=dword:00000001

Embedding a video with \embedvideo{<poster text/image>}{<video file>}; starred variant \embedvideo*{...}{...} for autoplay :

\documentclass{article}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \embedvideo{<poster or text>}{<video file (MP4+H264)>}
% \embedvideo*{...}{...}                     % auto-play
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[bigfiles]{pdfbase}
\ExplSyntaxOn
\NewDocumentCommand\embedvideo{smm}{
  \group_begin:
  \leavevmode
  \tl_if_exist:cTF{file_\file_mdfive_hash:n{#3}}{
    \tl_set_eq:Nc\video{file_\file_mdfive_hash:n{#3}}
  }{
    \IfFileExists{#3}{}{\GenericError{}{File~`#3'~not~found}{}{}}
    \pbs_pdfobj:nnn{}{fstream}{{}{#3}}
    \pbs_pdfobj:nnn{}{dict}{
      /Type/Filespec/F~(#3)/UF~(#3)
      /EF~<</F~\pbs_pdflastobj:>>
    }
    \tl_set:Nx\video{\pbs_pdflastobj:}
    \tl_gset_eq:cN{file_\file_mdfive_hash:n{#3}}\video
  }
  %
  \pbs_pdfobj:nnn{}{dict}{
    /Type/RichMediaInstance/Subtype/Video
    /Asset~\video
    /Params~<</FlashVars (
      source=#3&
      skin=SkinOverAllNoFullNoCaption.swf&
      skinAutoHide=true&
      skinBackgroundColor=0x5F5F5F&
      skinBackgroundAlpha=0.75
    )>>
  }
  %
  \pbs_pdfobj:nnn{}{dict}{
    /Type/RichMediaConfiguration/Subtype/Video
    /Instances~[\pbs_pdflastobj:]
  }
  %
  \pbs_pdfobj:nnn{}{dict}{
    /Type/RichMediaContent
    /Assets~<<
      /Names~[(#3)~\video]
    >>
    /Configurations~[\pbs_pdflastobj:]
  }
  \tl_set:Nx\rmcontent{\pbs_pdflastobj:}
  %
  \pbs_pdfobj:nnn{}{dict}{
    /Activation~<<
      /Condition/\IfBooleanTF{#1}{PV}{XA}
      /Presentation~<</Style/Embedded>>
    >>
    /Deactivation~<</Condition/PI>>
  }
  %
  \hbox_set:Nn\l_tmpa_box{#2}
  \tl_set:Nx\l_box_wd_tl{\dim_use:N\box_wd:N\l_tmpa_box}
  \tl_set:Nx\l_box_ht_tl{\dim_use:N\box_ht:N\l_tmpa_box}
  \tl_set:Nx\l_box_dp_tl{\dim_use:N\box_dp:N\l_tmpa_box}
  \pbs_pdfxform:nnnnn{1}{1}{}{}{\l_tmpa_box}
  %
  \pbs_pdfannot:nnnn{\l_box_wd_tl}{\l_box_ht_tl}{\l_box_dp_tl}{
    /Subtype/RichMedia
    /BS~<</W~0/S/S>>
    /Contents~(embedded~video~file:#3)
    /NM~(rma:#3)
    /AP~<</N~\pbs_pdflastxform:>>
    /RichMediaSettings~\pbs_pdflastobj:
    /RichMediaContent~\rmcontent
  }
  \phantom{#2}
  \group_end:
}
\ExplSyntaxOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{graphicx}

\begin{document}
\section{autoplay}
\embedvideo*{\includegraphics[page=1]{example-movie}}{example-movie.mp4}
\newpage
\section{play on click}
\embedvideo{\includegraphics[page=1]{example-movie}}{example-movie.mp4}
\end{document}
11
  • 1
    According to the following site: adobe.com/products/players/flash-player-distribution.html They are suggesting contacting HARMAN for more information.
    – Shawn Way
    Nov 12, 2019 at 13:18
  • 1
    Thanks. As for PDF and multimedia we will have to wait how Acrobat (Reader) will look like after Flash EOL. Maybe Adobe will publish another addendum to the ISO PDF specification.
    – AlexG
    Nov 12, 2019 at 13:46
  • This does not work for me. I tried Foxit, Adobe Reader both with Flash Player installed and removed. In the latter case Adobe Reader complains that it needs Flash Player. Jan 12, 2021 at 9:34
  • Do you use the most recent A-Reader DC version?. It definitely does not support Flash anymore.
    – AlexG
    Jan 12, 2021 at 9:41
  • 1
    This solution is for viewing with Acrobat Reader DC on Windows and Mac. The solution in the other answer also works with the Okular PDF viewer on Linux.
    – AlexG
    May 20, 2021 at 9:01
13

By using a screen annotation in pdf instead of a rich media annotation it is possible to get player configuration and player interaction. I found the following solution that met my needs:

\documentclass{beamer}
\usepackage{xkeyval}
\usepackage{media9}
\usetheme{CambridgeUS}
\usecolortheme{dolphin}
\usepackage{zref-abspage}

\makeatletter
\define@boolkey{simplemedia}{autoplay}{\def\simplemediaautoplay{#1}}
\define@boolkey{simplemedia}{showGUI}{\def\simplemediashowGUI{#1}}
\presetkeys{simplemedia}{autoplay=true,showGUI=true}{}

% all page-references relate to: Adobe PDF Reference, sixth edition, November 2006, can be found e.g.:
%https://ghostscript.com/~robin/pdf_reference17.pdf
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \simplemedia[<options>]{<poster or text>}{<media file>}{MIME type}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ExplSyntaxOn
%\cs_new:Npn\simplemedia[3][]{
\newcommand\simplemedia[4][]{%
  \setkeys{simplemedia}{#1}%
  \leavevmode
  \pbs_pdfobj:nnn{}{fstream}{{}{#3}}
  \pbs_pdfobj:nnn{}{dict}{
    /Type/Filespec/F~(#3)/UF~(#3)
    /EF~<</F~\pbs_pdflastobj:>>
  }
  %
  \pbs_pdfobj:nnn{}{dict}{
      /CT~(#4)% content type, page 764, table 9.9
      /D~\pbs_pdflastobj:% full file spcification, page 764, table 9.9
      /N~(Media~clip~from~#3)% name of media clip, page 764, table 9.8
      /P~<</TF (TEMPACCESS)>>% media permissions, page 764, table 9.9
      /S~/MCD% subtype media-clip-data, page 764, table 9.8
  }
  %
  \pbs_pdfobj:nnn{}{dict}{
      /C~\pbs_pdflastobj:% media clip dictionary, page 762, table 9.6
      /N~(RenditionFrom#3)% name of rendition, page 759, table 9.1
      /P~<<% media play parameters dictionary, page 762, table 9.6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Here's the point to switch on/off player GUI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        /BE~<</C~\simplemediashowGUI~%C: display a player-specific controller user interface, page 769, table 9.15
        /A~true>>~%A: automatically play when activated, page 770, table 9.15
        % select player (not used here)
%        /PL~<</A~[% arrray of media player info objects page 777
%%        <</PID~<</U~(vnd.adobe.swname:ADBE_MCI)~>>~>>~% PID: software identifier object, page 779
%        <</PID~<</U~(vnd.adobe.swname:MSFT_WindowsMediaPlayer)~/OS[(win16)~(win32)~(win9x)~(winnt)~(wince)]>>~>>~%/OS operating system, page 780
%        ]~>>
      ~>>
      /S~/MR% subtype of rendition, page 759, table 9.1
  }
  %
  \tl_set:Nx\mediarendition{\pbs_pdflastobj:}
  %  
  \pbs_pdfobj:nnn{}{dict}{}% obj-number created for later use
  \tl_set:Nx\renditionactionplay{\pbs_pdflastobj:}%
  %
  \pbs_pdfobj:nnn{}{dict}{}% obj-number created for later use
  \tl_set:Nx\renditionactionstop{\pbs_pdflastobj:}%
  %
  \hbox_set:Nn\l_tmpa_box{#2}% size of annotation
  \tl_set:Nx\l_box_wd_tl{\dim_use:N\box_wd:N\l_tmpa_box}
  \tl_set:Nx\l_box_ht_tl{\dim_use:N\box_ht:N\l_tmpa_box}
  \tl_set:Nx\l_box_dp_tl{\dim_use:N\box_dp:N\l_tmpa_box}
  \pbs_pdfxform:nnnnn{1}{1}{}{}{\l_tmpa_box}
  %
  \tl_set:Nx\l_simplem_current_page_tl{\zref@extract{simplem@\int_use:N\g_simplem_id_int}{abspage}}
  \pbs_pdfannot:nnnn{\l_box_wd_tl}{\l_box_ht_tl}{\l_box_dp_tl}{
      /T~(AnnotationFrom#3)~% title of screen annotation, page 640, table 8.38 
      /Subtype~/Screen~% Subtype Sreen, page 616, table 8.20 and page 640, table 8.38
      /BS~<</W~1/S/S>>% Borderstyle
      /C~[0.039216~0.039216~0.039216]% color used background, title bar, border, page 607, table 8.15
      /Contents~(EmbeddedAudiofile#3)% Text to be displayed, page 606, table 8.15
      /NM~(audioscreenannot:#3)% annotation name, page 606, table 8.15
      /AP~<</N~\pbs_pdflastxform:>>% appearance dictionary, page 606, table 8.15
      /F~4~%Annotation flag, page 606, table 8.15 and page 608, table 8.16
      /A~\renditionactionplay~% Action to be performed, page 640 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Here's the point to switch on/off autoplay
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      % autoplay is realised by "additional action" (page 640), 
      % PageOpen (PO) -> play "Play Rendition"
      % PageClose (PC) -> play "Stop Rendition" (see page 650)
      /AA~<<\ifKV@simplemedia@autoplay~/PO~\renditionactionplay~\fi~/PC~\renditionactionstop~>>~%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       see Adobe pdfmark-reference, I THINK, THIS WORKS ONLY WITH tex->dvips->ps2pdf
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      \int_compare:nT{\l_simplem_current_page_tl>0}{
        /P~\exp_args:Ne\pdf_pageobject_ref:n{\l_simplem_current_page_tl}
      }
      /CA~1%constant opacity value, page 618
  }
  % Rendition Action: "Play Rendition"
  \pbs_pdfobj:nnn{\renditionactionplay}{dict}{%
      /R~\mediarendition%
      /S~/Rendition
      /OP~4%operation to perform (page 669): 4 = play rendition specified by R
      /AN~\pbs_pdflastann:%
  }
  % Rendition Action: "Stop Rendition"
  \pbs_pdfobj:nnn{\renditionactionstop}{dict}{%
      /R~\mediarendition%
      /S~/Rendition
      /OP~1%operation to perform (page 669): 1 = stop rendition specified by R
      /AN~\pbs_pdflastann:%
  }
  %
  \phantom{#2}
  \zref@labelbyprops{simplem@\int_use:N\g_simplem_id_int}{abspage}
  \int_gincr:N\g_simplem_id_int
}%
\int_new:N\g_simplem_id_int
\ExplSyntaxOff
\makeatother

\begin{document}
\begin{frame}{Video inclusion with autoplay and showGUI}
\begin{columns}
\begin{column}[t]{128mm}
\begin{itemize}
\item command:\\
\scriptsize 
\texttt{\textbackslash{}simplemedia\{\textbackslash{}vbox to 3cm\{\textbackslash{}vfil\textbackslash{}hbox to 5cm\{\}\textbackslash{}vfil\}\}\{sample-5s.mp4\}\{video/mp4\}}
\normalsize
\item result:
\simplemedia{\vbox to 3cm{\vfil\hbox to 5cm{}\vfil}}{sample-5s.mp4}{video/mp4}
\hspace{0.5cm}\tiny{}https://samplelib.com/sample-mp4.html
\end{itemize}
\end{column}
\end{columns}
\end{frame}


\begin{frame}{Audio inclusion with autoplay and GUI}
\begin{columns}
\begin{column}[t]{128mm}
\begin{itemize}
\item command:\\
\scriptsize 
\texttt{\textbackslash{}simplemedia\{My audio\}\{sample-6s.mp3\}\{audio/mp3\}}
\normalsize
\item result:
\simplemedia{My audio}{sample-6s.mp3}{audio/mp3}
\hspace{0.5cm}\tiny{}https://samplelib.com/sample-mp3.html
\end{itemize}
\end{column}
\end{columns}
\end{frame}

\begin{frame}{Audio inclusion with autoplay, no GUI}
\begin{columns}
\begin{column}[t]{128mm}
\begin{itemize}
\item command:\\
\scriptsize 
\texttt{\textbackslash{}simplemedia[showGUI=false]\{My audio\}\{sample-6s.mp3\}\{audio/mp3\}}
\normalsize
\item result:
\simplemedia[showGUI=false]{My audio}{sample-6s.mp3}{audio/mp3}
\hspace{0.5cm}\tiny{}https://samplelib.com/sample-mp3.html
\end{itemize}
\end{column}
\end{columns}
\end{frame}

\begin{frame}{Audio inclusion without autoplay}
\begin{columns}
\begin{column}[t]{128mm}
\begin{itemize}
\item command:\\
\scriptsize 
\texttt{\textbackslash{}simplemedia[autoplay=false]\{Klick here to start\}\{sample-6s.mp3\}\{audio/mp3\}}
\normalsize
\item result:
\simplemedia[autoplay=false]{Klick here to start}{sample-6s.mp3}{audio/mp3}
\hspace{0.5cm}\tiny{}https://samplelib.com/sample-mp3.html
\end{itemize}
\end{column}
\end{columns}
\end{frame}

\end{document}

It is based on the flash-free example above and works with latex->dvips->ps2pdf and thanks to AlexG also with pdflatex (lualatex and xelatex should work, too). The pdf-file plays with my actual Acrobat Reader DC and also with Foxit Reader (both under Windows). My Acobat XI (from 2012) doesn't support mp4 and only the mp3 examples are playing. In all cases you have to trust the document first.

Regards, Fritz

12
  • pdftex doesn't have a command to reference "ThisPage", but you can use \pdf_pageobject_ref:n{<absolute page number>}, you then only need a label/ref to get the page number. That is rather easily done with e.g. zref. Beside this looks quite nice, I could embed the example-movie.mp4 from mwe. Apr 14, 2021 at 13:19
  • @Fritz I see, you should use Ulrike's approach to get the page object reference then.
    – AlexG
    Apr 15, 2021 at 16:13
  • Thanks for your hint, I will try. Many extensions are conceivable, but the task to pump this solution up to an allround solution (as your media9 package) is actual to big for me. I have no experience with "base-level" Latex2e commands.
    – Fritz
    Apr 15, 2021 at 16:46
  • I have used your code and added the page object reference using the zref package. I am going to send it to you by e-mail. Then it will also work with pdflatex and xelatex.
    – AlexG
    Apr 15, 2021 at 16:53
  • Thank you very much. I got it.
    – Fritz
    Apr 16, 2021 at 7:48
10

As elaborated here and here Flash support has been discontinued. But Adobe Reader DC (I have version 21.001.20142) I get pdf documents compiled with mp4 videos.

In my document I used the following code snipped with the media9 package:

        \includemedia[
    width=0.6\linewidth,
    height=0.7\linewidth,
    keepaspectratio,
    activate=pageopen,
    playbutton=fancy,
    addresource=figures/80deg90.mp4,
    flashvars={source=figures/80deg90.mp4&autoPlay=true}
    ]{}{VPlayer.swf}

I got an compiled pdf. First I was not able to see the video in Adobe Reader DC, but with this settings mentioned in here, I got it working:

 1. Go to Windows Settings > Display > Graphic Settings > Under Choose an App/ Browse >
 2. Add Acrobat.exe and edit the default from "Let Windows decide" to Power Saving Intel.
 3. Relaunch Acrobat.
 4. Try to play video. 

The full solution of the previous answer, you find here running in overleaf. I can compile the document and run it in Adobe Reader DC as well.

5
  • Can't open link May 15, 2021 at 6:44
  • The example is here: overleaf.com/read/rcfqksxktygc. I've put it in the edit queue to get it added to the post.
    – user7868
    Aug 24, 2021 at 5:49
  • This answer works for me on Windows 10 + Adobe Reader DC !
    – Guillaume
    Sep 13, 2021 at 13:22
  • This also works for me on linux (Ubuntu 20.04) with Okular PDF viewer (1.9.3). The only thing that doesn't work is the playbutton.
    – sega_sai
    Jan 3, 2023 at 20:38
  • 1
    @user7868 the link in your comment is no longer valid
    – ric.san
    May 31, 2023 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .