If I have a video at a known frame rate, and a time series of sensor readings taken at the same time. How can I play back the video and show a relevant section of the time series so the two are in sync, say the time series plot starts 1 second before the current frame and shows 2 seconds of the time series.


1 Answer 1


Use TimeSeriesShift to adjust your time series first. I have not handled that aspect of the question below, but rather the way to get the time out of a video stream and use it for live plotting, which is kind of non-trivial and worth answering here:

This video stream player is straight out of the documentation:

stream = VideoStream["ExampleData/bullfinch.mkv"];
      "Seconds"], (stream["Position"] = #) &], {0, 
     QuantityMagnitude[stream["Duration"], "Seconds"]}],
    Dynamic[If[stream["Status"] === "Playing", "Pause", "Play"]],
    If[stream["Status"] === "Playing", VideoPause[stream], 
   }, Alignment -> Center]

I generate a random time series:

(* example time series *)
ts = RandomFunction[WienerProcess[0, 1.5], {0, 50, .05}];

... and I create a dynamic plot. The ImagePadding is important to stop it jumping around. I also plot only a 2 second window so that the plot scrolls horizontally:

 With[{t = QuantityMagnitude[stream["Position"], "Seconds"]},
  DateListPlot[ts, PlotRange -> {{t - 2, t}, {-10, 10}},
   AspectRatio -> 1, ImagePadding -> 20

video with plot


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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