1

I can embed videos in Beamer either with \movie of multimedia, or \includemedia of media9.
In the first case, videos are correctly displayed in Okular (Linux). In the second case, I use Adobe Reader (Windows). However, using \movie is much better: the pdf is compiled faster, it is smaller, and videos are loaded faster during the presentation.
I tried Okular for Windows (from the Microsoft Store) but videos are not displayed. Is there any reader for \movie for Windows?

EDIT

According to this answer, it should be possible to use \movie with Adobe on Windows if the movie is in .avi or .mov. I tried .avi and it does not work. The video still takes time to be loaded, the pdf is still big, and the video does not even play (I get the typical plugin error icon, saying that Adobe is not able to read the source). Still looking for an alternative to Adobe for Windows...

  • I can only reiterate what was said in the linked answer: (1) To be usable in Acrobat Reader, multimedia+\movie is limited to AVI as video container format and the antique "MS Video 1" codec used for making the video. The video file remains separate from the PDF. Therefore, faster loading. (2) MP4/H264 is the video format to be used with \includemedia from media9 package. Videos take longer to be played, because they are compressed and embedded in the PDF und thus must be unpackaged and decompressed first. – AlexG Dec 17 '19 at 6:33
  • An alternative PDF viewer for Windows might be Foxit Reader. I am unsure about its requirements, but I guess they are similar to AR. – AlexG Dec 17 '19 at 6:39
  • Also, for faster loading of video files and using media9 + \includemedia you could try this local web-server based method: tex.stackexchange.com/q/72993 – AlexG Dec 17 '19 at 6:56
1

For playback of large video files in the modern MP4/H.264 format using package media9 and Acrobat Reader, the web-server method should be used. Even a 275 MB video file immediately starts playing while being loaded in the background. With this method, the video file is not embedded in the PDF.

A local video file can as well be served by a locally running, lightweight web server such as Nginx. See https://tex.stackexchange.com/a/73039 for instructions.


Edit:

The command

\mediaopts{<media label>}{[autoplay] [, autopause] [, autorewind]}

%   autoplay   -> play / resume on page-open
%   autopause  -> pause on page-close
%   autorewind -> seek to start on page-close

was added. It allows one to control the media behaviour during page open and page close events. Paused media continue to be loaded in the background.


This is a large video example, using the "Big Buck Bunny" example from Blender.org:

\documentclass{beamer}

\usepackage{fontawesome5}
\usepackage{media9}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \mediaopts{<media label>}{[autoplay] [, autopause] [, autorewind]}
%
%   autoplay   -> play / resume on page-open
%   autopause  -> pause on page-close
%   autorewind -> seek to start on page-close
%
%   Place command directly after \includemedia[...]{...}{...} 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ExplSyntaxOn
\NewDocumentCommand\mediaopts{mm}{
  \group_begin:
  \leavevmode
  %reset actions
  \tl_clear:N\l_mix_openact_tl \tl_clear:N\l_mix_closeact_tl
  %process list of actions
  \tl_if_exist:cTF{ann@#1}{
    \str_if_eq:eeF{\tl_use:c{ann@#1}}{draft}{
      \clist_map_inline:nn{#2}{
        \str_case:nn{##1}{
          {autoplay}{
            \mix_pdfobj:nnn{}{dict}{
              /S/RichMediaExecute /TA~\tl_use:c{ann@#1} /TI~\tl_use:c{main@#1}
              /CMD~<</C~(play)>>
            }
            \tl_set:Nx\l_mix_openact_tl{\mix_pdflastobj:}
          }
          {autopause}{
            \mix_pdfobj:nnn{}{dict}{
              /S/RichMediaExecute /TA~\tl_use:c{ann@#1} /TI~\tl_use:c{main@#1}
              /CMD~<</C~(pause)>>
            }
            \tl_put_right:Nx\l_mix_closeact_tl{\mix_pdflastobj:}
          }
          {autorewind}{
            \mix_pdfobj:nnn{}{dict}{
              /S/RichMediaExecute /TA~\tl_use:c{ann@#1} /TI~\tl_use:c{main@#1}
              /CMD~<</C~(rewind)>>
            }
            \tl_put_right:Nx\l_mix_closeact_tl{\mix_pdflastobj:}
          }
        }
      }
      %insert widget annotation
      \mix_pdfannot:nnnn{3bp}{3bp}{0pt}{
        /Subtype/Widget /T~(mbtn@\int_use:N\g_mix_mbtncnt_int) /FT/Btn/Ff~65537
        /AA~<<
          /PO~<<
            /S/JavaScript/JS~(
              if(typeof(annotRM)=='undefined'){annotRM=new~Array();}
              if(typeof(annotRM['#1'])=='undefined'){
                annotRM['#1']=this.getAnnotRichMedia(\tl_use:c{page@#1},'#1');
              }
              annotRM['#1'].activated=true;
            )
            \tl_if_empty:NF\l_mix_openact_tl{/Next~\l_mix_openact_tl}
          >>
          \tl_if_empty:NF\l_mix_closeact_tl{
            /PC~<</S/Named /N/NOP/Next~[\l_mix_closeact_tl]>>
          }
        >>
      }
      \mix_appendtofields:n{\mix_pdflastann:}
      \int_gincr:N\g_mix_mbtncnt_int
    }
  }{
    \msg_warning:nnx{media9}{undefined~reference}{#1}
    \cs_if_exist:NF\g_mix_refundefwarned_tl{
      \tl_new:N\g_mix_refundefwarned_tl
      \AtEndDocument{\msg_warning:nn{media9}{undefined~references}}
    }
  }
  \group_end:
}
\ExplSyntaxOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{frame}{Start}
\end{frame}

\begin{frame}{Remote video}
  \noindent\includemedia[
    label=bunny,
    width=\linewidth,height=0.5625\linewidth, % 16:9
    activate=pageopen,
    deactivate=onclick, % keep FlashPlayer activated
    passcontext,
    flashvars={
%       source=http://localhost/bbb_sunflower_1080p_30fps_normal.mp4
       source=http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4
      &autoPlay=true
    }
  ]{}{VPlayer.swf}%
  \mediaopts{bunny}{autoplay,autopause}

  \mediabutton[mediacommand=bunny:pause, mediacommand=bunny:rewind]{\faStop}\quad
  \mediabutton[mediacommand=bunny:playPause]{\faPlay / \faPause}
\end{frame}

\begin{frame}{End}
\end{frame}

\end{document}
| improve this answer | |
  • Thanks, but it is even slower. The pdf is ligher and compiled fast, but the videos need to be loaded every time. (I see the gray "video template" with the play button and a loading bar). Even if I load it, then go forward and back to the slide, the video has to be loaded again (so I cannot "preload" them). – Simon Dec 17 '19 at 13:09
  • Loading the video on every page-open isn't a problem actually, since it starts playing immediately or with at most 3 secs delay when playing for the first time. The time is taken to load the FlashPlayer plugin. See updated example (now with beamer class). – AlexG Dec 17 '19 at 13:55
  • The things is that there is still some delay before the slide is loaded, which is what I want to avoid. And in the case of larger videos, this delay is worse than embedding the video. Having the loading bar is ok-ish, even if in some cases the video stops for a fraction of seconds, lagging a bit. – Simon Dec 17 '19 at 14:08
  • Objection! The video length has no effect on the loading time as playback is started immediately once FlashPlayer has been activated. I modified the example once again. Now PlashPlayer is not unloaded on leaving the slide. There is zero delay now when visiting the video slide for the second time. However, the video continues playing when leaving the slide unless you click one of the buttons below. Note that loading the video file is faster if you get it from a locally running web server. (And the video is really big in my example.) – AlexG Dec 17 '19 at 14:37
  • Thanks, this works much better. Ofc having the video always running in background may not be the best thing, if I need that the video starts from the beginning, but this time I am fine :) The only thing is that, after I pre-load all videos, the next time I open the slide I have to manually click on the video because it is paused. Not a big deal, but is there a way to avoid this? Thanks! Also, more related to the original question: why can't Okular on Windows reproduce videos with \movie? (Btw I tried Foxit and does not work) – Simon Dec 18 '19 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.