41

I'd like to embed a YouTube video inside a PDF generated by LaTeX, now I know it is possible to embed videos using the movie15 package but that includes the video in the PDF.

I was hoping there would be some way to embed the video as a flash object that streams it from YouTube when you get to the slide.

Anyone managed to do it before?

2
  • 1
    Are there PDF viewers which support Flash? The embedding is only the first half. The viewer must support it as well. Commented Apr 1, 2011 at 19:15
  • @Martin latest Acrobat can embed flash video, no idea if it can stream it though
    – Ravi
    Commented Apr 1, 2011 at 19:35

4 Answers 4

25

Edit

Notice of obsolescence:

YouTube have dropped their Flash-based video player in Sept 2017. For the lack of HTML5 support in the PDF specification (and thus by PDF viewers), YT playback is not possible anymore in an embedded fashion.

Alternatively, the SVG format allows embedded playback of HTML5 video, including YouTube and Vimeo. Package media4svg is available for this purpose. It requires a workflow via DVI (dvilualatex/latex + dvisvgm). Example: http://mirrors.ctan.org/macros/latex/contrib/media4svg/example/beamer-example-3.svg


Original answer

\documentclass{article}
\usepackage{media9}             %pdflatex, latex+dvips+ps2pdf, xelatex
%\usepackage[dvipdfmx]{media9}  %latex+dvipdfmx

\begin{document}
\includemedia[
  width=0.6\linewidth,height=0.45\linewidth,
  activate=pageopen,
  flashvars={
    modestbranding=1 % no YT logo in control bar
   &autohide=1       % controlbar autohide
   &showinfo=0       % no title and other info before start
  }
]{}{http://www.youtube.com/v/<video id>?rel=0}   % Flash file
\end{document}

<video id> to be replaced by the video ID, i. e., something like Mdc3o7wOwNA. More FlashVars for configuring the youtube video player are documented here. Some FlashVars, such as rel=0, seem to have effect only if appended to the URL.

7
  • Only downside: it doesn't seem to be working with the Linux version of Acrobat Reader 9 :(
    – PierreBdR
    Commented Apr 24, 2013 at 8:35
  • @PierreBdR: Yeah, they (Adobe) seem to have abandoned further development of AR on the Linux platform. Last thing they did was disabling the embedded FlashPlayer :(.
    – AlexG
    Commented Apr 24, 2013 at 8:47
  • It might be due to updates of the packages between your post and now, but it gives the error ! Undefined control sequence. <recently read> \__scan_new:N l.54 \__scan_new:N \s__tl
    – Betohaku
    Commented Apr 24, 2013 at 16:30
  • 1
    @Betohaku : At least version 0.24 as of 2013-02-21 of media9 is required.
    – AlexG
    Commented Apr 25, 2013 at 6:17
  • 1
    I get the same error as @PierreBdR when formatting the above code using MiKTeX v2.9 and the latest version of media9. I replaced the <video id> with a video ID. What am I doing wrong?
    – Tom Price
    Commented Sep 12, 2013 at 12:30
9

The y4pdf package is [no more] what you need !

EDIT : Please note this answer is now obsolete and this package does not seems to be supported anymore, and if you ever manage to compile the package, the resulting PDF won't play the video.

6
  • 4
    Oh, this wont work with pdflatex alone: "Rich media annotation is a feature of Acrobat/Adobe Reader version 9. Acrobat Pro and Distiller version 9.0 or later are required to build a document, and Adobe Reader 9.0 or later is needed to activate the annotation and play the media." Commented Apr 1, 2011 at 19:34
  • 2
    note that movie15 was superseded by media9, some time back. we (ctan and karl berry) were assured by the author that media9 does do the necessary with pdflatex, and that development for other viewers than acro* is underway. Commented Feb 5, 2013 at 19:37
  • @Magix Are you sure? Apart from the difficulties I encountered when I tried to compile any of the yt4pdf examples (too many requirements/dependencies, e.g. Acrobat Distiller, acrotex, rmannot packages), the method seems to be obsolete anyway, since the pre-compiled examples do not work anymore.
    – AlexG
    Commented Jan 28, 2016 at 9:18
  • @AlexG i am not the author of this answer, i just edited it because it was terrible. So if you ask me, no, i'm not sure ;-)
    – Magix
    Commented Jan 28, 2016 at 9:20
  • @Magix: Well, the exclamation mark of your edited answer made me think you are a staunch user.
    – AlexG
    Commented Jan 28, 2016 at 9:27
1

Flash support has discontinued from Dec 2020. At least Media9 no longer works as above. Fixes are in Alternatives

0

maybe ltx4yt package may work. Get it from https://www.ctan.org/pkg/ltx4yt

You must log in to answer this question.

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