7

I'm looking to import 100 image frames from an mp4 video file at roughly evenly spaced intervals. As $ImportFormats shows, Mathematica can handle

  • Movie files: .avi, .mov, .qt, .flv
  • Multiframe images: .swf, .tiff, .gif

If I convert the video it to a supported type, what would the syntax be to achieve this import, I don't want to import all the frames and then take a few!

M.R.
  • 31,425
  • 8
  • 90
  • 281

1 Answers1

10

You can use Import directly as follows:

Import["MVI_9855-183.mp4", {"AVI", "ImageList", Range[1, 110, 20]}]

This will import one frame every 20, between the first and 100th, and return them as a list of pictures.

Mathematica graphics

As you can see above, at least in the case of the mp4 files I have at hand I was able to "convince" Mathematica to import them directly by specifying the AVI format for the file. I am no expert in video file format, however, so I can't claim that I understand why that worked, or whether it will work for you as well.


If you are on Windows, you may also be interested in Simon Woods's MathMF package that carried out video input output functions using Windows Media Foundation. See it described in his answer to this question: Importing videos in Mathematica

MarcoB
  • 67,153
  • 18
  • 91
  • 189