5

I am a noob in adding animations. I'm making progress, but new problems apparently show up all the time. Hardly a surprise actually. Anyway.

System: WinEdt 7.0, MikTeX 2.9, Windows 7

\documentclass{powerdot}

\usepackage{lmodern}
\usepackage[utf8]{inputenc}
%\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[finnish]{babel}

\usepackage{amsmath,amssymb}
%\usepackage{psfrag}
\usepackage{media9}

\begin{document}
\begin{slide}{Esimerkki D1}
Sykloidiksi kutsuttu käyrä on $x$-akselia pitkin sutimatta vierivän yksikköympyrän kehältä
kiinnitetyn yhden pisteen ympyrän pyöriessä piirtämä käyrä.
\includemedia[
      width=200pt,
      height=70pt,
      activate=pageopen,
    ]{}{sykloidi.swf}
\end{slide}
\end{document}

The file sykloidi.swf is a video of a cycloid being drawn (generated by Mathematica, but that is probably irrelevant).

The above compiles all right via the DVI->PS->PDF route. The resulting PDF slide set looks good otherwise, but when I started zooming in Adobe Reader (going to full screen mode is enough) I was very surprised to notice that the size of the animated area remained the same, and the gap created by zooming is filled in with black.

This is IMHO bizarre. I do realize at some level that video may have a built-in unscalable resolution, but SWF is vector graphics, and it is supposed to scale, right?

I tried to insert a scale variable (giving it a modest value like 1.2), but that only made the surrounding box bigger (it overflowed outside the slide eventually).

So how does the syntax of scaling work in media9? I tried to find it in this document, but unfortunately couldn't make head or tails out of that. Is there something like "media9 for dummies" somewhere that you would recommend? Googling gave some hits, but the documents referred to external programs in Mac OS or seemed to depend on TikZ or...

Edit1: I know nothing about the internal structure of various video formats. But still images (irrespective of whether they were originally .png, .eps) scale with the rest of the document when viewed in Adobe Reader, why is video different? I realize that the problem may be elsewhere, in which case I should ask, whether anyone can diagnose the problem.

Edit2: It is possible that the technically correct term I need is resizable as opposed to scalable. As I said, I'm ignorant about such differences.

  • Further testing. When I export the animation from Mathematica as an .avi as opposed to a .swf, and view it in WindowsMediaPlayer, the effect is the same in the sense that resizing the window does not resize the animation. Is this just a fact of life or a quirk of many a video format? – Jyrki Lahtonen Dec 5 '13 at 6:48
  • Declaring width=linewidth instead of a fixed size only affects the size of the box surrounding the animation, not the size of the animation itself. – Jyrki Lahtonen Dec 5 '13 at 7:16
  • 1
    SWF isn't video basically, but a vector file format with the capability to also wrap bitmapped material as well as video streams. The way how to scale its content is completely up to sykloidi.swf. Why don't you generate an mp4 video file and load it into VPlayer.swf? – AlexG Dec 5 '13 at 8:24
  • 1
    It should solve it. VPlayer.swf can be configured to use various scale modes via FlashVars: none (the one you experience with Mathematica generated SWF), letterbox, stretch, zoom. Try exporting the animation frames as numbered PNG graphics files. You can first combine them to an uncompressed AVI video using some Windows tool and then convert this AVI to MP4/H.264 video by means of an online service (video.online-convert.com/convert-to-mp4) – AlexG Dec 5 '13 at 12:09
  • 1
    Thank you, @AlexG. This did solve my problem. It is possible to Export the animation from Mathematica in AVI, and the link you gave converted that to MP4. After a few rounds of trial and error, I managed to get it done. Still a lot to learn about (adding the functionality of MediaButtons, finetuning frame rate, other params,...) but with a piece of working out the immediate probelm is out of the way. I will post a list of "How to" steps. But if you want to add something else to it, I will happily upvote & accept that. – Jyrki Lahtonen Dec 5 '13 at 20:24
5

The scaling behaviour (Stage.scaleMode property, see ActionScript-2 reference) of Mathematica-generated SWF files is hard-coded to noScale.

Although SWF is binary, the place in the file where Stage.scaleMode is defined, can be edited in some text editors, such as vi or sed. Fortunately, the string noScale has the same length as showAll and we can replace the former with the latter, without corrupting the SWF file:

sed -i 's/noScale/showAll/' sykloidi.swf

showAll as the value of scaleMode will produce the wanted behaviour.

| improve this answer | |
  • Thank you very much for researching this! I need to try this out. – Jyrki Lahtonen Dec 18 '13 at 8:30
  • 1
    It turned out that calling Mathematica's Export function with the correction options does make the resulting SWF scalable. I tested that approach, and it works as well. Thank you once more for the time you spent on this. – Jyrki Lahtonen Dec 21 '13 at 17:29
6

Here's how I solved the problem using several bits of advice from AlexG. Listing the steps here just in case somebody else will later have problems figuring out how to port a Mathematica animation into a powerdot/media9 slide set.

  • Export the animation from Mathematica in AVI-format. The online help of Mathematica gives you the syntax of that command.
  • Use this online service to convert the AVI to MP4. Of course, there are other ways of doing this, but I found ffmpeg a bit intimidating :-)
  • For very basic functionality use a code-snippet like the following:

    \includemedia[
          width=200pt,
          height=200pt,
          addresource=./sykloidi.mp4,
          activate=pageopen,
          flashvars={source=./sykloidi.mp4&loop=true}
        ]{}{VPlayer.swf}
    
  • You need to click the animation area with a mouse, and hit the spacebar to pause/continue, if you do it exactly like this. There are other options. See the package documentation for those. Here sykloidi.mp4 is the out put of the converter. I keep it in the same folder as the source code, so I didn't need to type in the entire path.

I tested this and now the animation area will resize as desired, when I zoom the Adobe Reader view of the produced slide set.

| improve this answer | |
  • Glad to hear you were successful! For best output quality of the final MP4 video try to use a lossless compression method for the intermediate AVI. Which one did you use? – AlexG Dec 5 '13 at 20:44
  • @AlexG: IDK. Need to study the documentation. The AVI-files produced by Mathematic are relatively large - the animation of drawing of cycloid was 35MBytes (is that large for a few seconds?), and the compressed MP4 was 57 kBytes. I don't know whether that suggests that the AVI was lossless compression or no compression? Also that online service allows several options that I can tinker with. If I zoom in alot, the default compression does make it look a bit cruddy, so I will continue my studies. But now I need to catch some shuteye - last night went till 2:30 with this. – Jyrki Lahtonen Dec 5 '13 at 21:09

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.