I would like to have a video in my pdf that plays when you click on it. When the video is not playing it should show a figure. When I compile my pdf I do get a figure that I can click on, but it turns blank when I click on it, and no video plays. I don't get any errors either. This is my code:

\usepackage{media9} %this is specified somewhere at the start of the file

\includemedia[label=videofile, width=1.0\textwidth, addresource=./Videos/videofile.mp4,
  • Try using VPlayer9.swf instead – alfC Feb 18 '14 at 16:58

Your video file seems to be corrupt/using the wrong video codec. I successfully tried your example with file random.mp4 (h.264 codec) from the media9 package.

Note, that with the current configuration, on clicking once, VPlayer.swf will be activated only. To have the video start playing after one click, you must append &autoPlay=true to the flashvars option. Alternatively, you could put activate=pageopen to the options list of \inlcudemedia. Then, VPlayer.swf will be automatically activated showing the first frame of the video file and obscuring the embedded poster graphics file. The first click will start playback.

Further note that one of the width options (\includegraphics or \inlcudemedia) is redundant.

The label option is only needed if you want to refer to this media inclusion from a \PushButton with JavaScript or a \medialink (soon to come).

  • I have implemented your comments and I've tried another mp4 file, but still it does not work. It now gives an error: Unable to play './Videos/videofile.mp4'. In case I use the StrobeMediaPlayback.swf, I get error #1009. What do you mean by h.264 codec and how do I implement this? – Wouter Jan 17 '13 at 15:55
  • The video producing software should use h.264 codec for video compression. MP4 is only a container. Another usable file format is FLV. MP4/H264 and FLV can be produced with ffmpeg. See the second page of media9 documentation on how to use ffmpeg. – AlexG Jan 17 '13 at 16:05
  • I've converted my file to FLV and now it works! Thank you for your comments. By the way, in the media9 manual they talk about using ffmpeg in the command line, but I'm unsure where to put this to make it work with an mp4 file. – Wouter Jan 18 '13 at 13:42
  • ffmpeg is a command line tool, that is, it has no windows-like graphical user interface for input of parameters. It must be used at the command line (the black DOS window 'cmd.exe' under Windows, 'Terminal' in OSX). – AlexG Jan 18 '13 at 14:22
  • What was the complete code that made this work? – A Feldman Apr 30 '16 at 9:46

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.