6
$\begingroup$

I am running Mathematica 11.1.1 on Win 10 64 bit.

How can this uncompressed avi movie be read into a list of images without having installed Quicktime? I do not succeed. Windows Media Player and VLC can play it without Quicktime.

Movie (35 MB):

https://drive.google.com/open?id=0B9wKP6yNcpyfNENvNHJMRGc0SG8

Please try the following code:

avifile = "20170628_movie_01.avi"; 
numberImages = Length@Import[avifile, "Frames"]  
(* Out: 115 *)

Import[
   avifile, {{"BitDepth", "ColorSpace", "Duration", 
     "FrameCount", "FrameRate", "ImageSize", "VideoEncoding"}}]   
(* Out: {8, RGBColor, 7.59, 115, 15.1515, {640, 480}, "Uncompressed"} *)

images = Import[avifile, {"AVI", "ImageList"}]    
(* Import::fmterr: Cannot import data as video format. *)   
(* $Failed *)
$\endgroup$
  • $\begingroup$ Mathematica version and operating system? I can get the images using version 9 or later, but get the Import::fmterr if I use version 8. $\endgroup$ – Jason B. Jun 28 '17 at 15:43
  • $\begingroup$ @Jason. B: Mathematica 11.1.1, Win 10 Pro 64. Can you get the images without Quicktime? Which decoder is used - can you control it? $\endgroup$ – mrz Jun 28 '17 at 19:53
  • $\begingroup$ I'm on a mac so I don't think I can be without quicktime, right? $\endgroup$ – Jason B. Jun 28 '17 at 19:55
  • 2
    $\begingroup$ This question seems relevant: mathematica.stackexchange.com/questions/161/… $\endgroup$ – Musang Jul 3 '17 at 13:14
  • 2
    $\begingroup$ It looks like JMF can't handle the palletized video stream (note you have RGB color but only one byte per pixel). You will need to use another application such as ffmpeg to decode the video. $\endgroup$ – Simon Woods Jul 3 '17 at 21:03
5
$\begingroup$

Solution with MathMF from Simon Woods (here and here):

The code for sequentially reading images of an avi movie is very fast.

Needs["MathMF`"];
MFInitSourceReader[avifile];

numberImages = Length@Import[avifile, "Frames"];

Do[

  image = MFGrabFrame["ByteImage"];

  (* additional code *)

  , {i, 1, numberImages}
];

Answer from Wolfram Technical Support.

I understand that Mathematica cannot import some AVI file.

This is due to that Mathematica is not shipped with decoders.

We suggest converting the video file into a .gif file first. For example, you can use ImageMagick. I tested with your .avi file that a .gif file converted by ImageMagick is able to be imported with Mathematica.

Since I am working with large video data files of about 100 GB I prefer the solution of Simon Woods.

$\endgroup$
  • 1
    $\begingroup$ You need to evaluate numberImages = Length@Import[avifile, "Frames"]; only once before starting the Do loop, not inside of the latter. $\endgroup$ – Alexey Popkov Jul 6 '17 at 3:25
  • $\begingroup$ @Alexey Popkov: yes ... in my original code I did it ... I mixed it up ... thanks $\endgroup$ – mrz Jul 6 '17 at 8:05

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.