1
$\begingroup$

I'm tying to export a table of images to a quicktime movie with a set duration (in this example, 12.67 seconds)

atable = Table[
   Show[
    ListLinePlot[{dataSet[[a ;; a + w]], filtered[[a ;; a + w]]}, 
     PlotRange -> {-3, 3}],
    Graphics[{Red, PointSize[Medium], 
      Point[dataSet[[Round[a + w/2]]]]}]
    ],
   {a, 1, Length[dataSet] - w - (Length[dataSet] - Length[filtered]), 
    1}];

I first tried setting the "Duration" to 12.67 seconds, and got a 1:05 video instead:

Export["~/Desktop/tableAnimation.mov", atable, "QuickTime",  "Duration" -> duration]

(Here duration is 12.6)

Then I realised Export aways set a default framerate of 15 FPS (with 979 frames, 15FPS -> 65 seconds)

So i tried t set the framerate to 979/12.675:

Export["~/Desktop/tableAnimation.mov", atable, "QuickTime",  "FrameRate" -> (Length[atable]/duration)]

But I always get an 11 second video (85.71 FPS instead of about 77FPS)

Note that when I set the framerate to 30 (just for a test) I actually did get a 30 FPS video

Why aren't I getting the framerate I am asking for ?

Thank you

Complete code below :

filtered = aYFilteredPlotData;
raw = accYPlotData;
startTime = accT[[1]];
endTime = Last[accT];
duration = endTime - startTime;
w = 300;

frames = Table[
   Show[
    ListLinePlot[{raw[[a ;; a + w]], filtered[[a ;; a + w]]}, 
     PlotRange -> {-3, 3}],
    Graphics[{Red, PointSize[Medium], Point[raw[[Round[a + w/2]]]]}]
    ],
   {a, 1, Length[raw] - w - (Length[raw] - Length[filtered]), 1}];

Export["~/Desktop/tableAnimation.mov", frames, "QuickTime", 
 "FrameRate" -> (Length[frames]/duration)]

Where: raw and filtered are the datasets being plotted (a collection of {x,y} values)

They are accelerometer data and their timestamps I use the first and last timestamps to calculate duration and framerate

$\endgroup$
8
  • $\begingroup$ If you're on a Mac, the duration is produced very accurately by "FrameRate" -> (Length[atable]/duration)]. So unfortunately I cannot reproduce the issue. What OS and Mathematica version do you use? $\endgroup$
    – Jens
    Jun 6, 2016 at 3:34
  • $\begingroup$ Hi Jens, I'm on Mathematica 10.0.0 and OS X El Capitan 10.11.4. $\endgroup$
    – kmn
    Jun 6, 2016 at 8:40
  • $\begingroup$ It might help if you add the complete code to produce a movie that shows the issue. You could also try this $\endgroup$
    – Jens
    Jun 6, 2016 at 15:38
  • $\begingroup$ HI @Jens, The complete code is added, I'll check out your link $\endgroup$
    – kmn
    Jun 7, 2016 at 11:47
  • $\begingroup$ Hi Jens, using the script in the link returns this error : PadRight::normal: Nonatomic expression expected at position 1 in PadRight[0.0129468,979,0.0129468]. >> (Note that the frame duration here is 0.0129468) $\endgroup$
    – kmn
    Jun 7, 2016 at 12:05

1 Answer 1

3
$\begingroup$

There was no problem exporting at the correct frame rate when I initially tried it with a small number of test frames, given that the code in the question doesn't produce any actual frames. However, I now tried again with a large table of frames to replicate the specific number of 979 frames in the question. Indeed, in this case the resulting movie has the wrong duration of 11 seconds instead of the desired 12.67.

I now thin this is because Quicktime export uses a time scale that is too coarse to accurately describe the extremely short frame durations that correspond to cramming 979 frames into 12.67 seconds.

The time scale is given as a fraction of a second. In my answer here I explicitly set it to $1/600$ seconds. But in Mathematica's Export this value may be different. The duration of each individual frame is then turned into an integer multiple of this time scale. At this point, rounding errors come in, which is probably the reason for the discrepancy in the final duration of the movie.

$\endgroup$
1
  • $\begingroup$ Jens, you were right. It ended up working after I resampled my table of frames. Thank you. $\endgroup$
    – kmn
    Jul 2, 2016 at 21:54

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.