6

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 *)
mrz
  • 11,686
  • 2
  • 25
  • 81
  • 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. – Jason B. Jun 28 '17 at 15:43
  • @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? – mrz Jun 28 '17 at 19:53
  • I'm on a mac so I don't think I can be without quicktime, right? – Jason B. Jun 28 '17 at 19:55
  • 2
    This question seems relevant: https://mathematica.stackexchange.com/questions/161/importing-videos-in-mathematica – Musang Jul 03 '17 at 13:14
  • 2
    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. – Simon Woods Jul 03 '17 at 21:03
  • @Simon Woods: Also here your software MathMF is solving the problem, like you showed it in https://i.stack.imgur.com/qhu5j.png . – mrz Jul 05 '17 at 11:23
  • @Simon Woods: Also here as in https://mathematica.stackexchange.com/questions/148928/how-to-extract-all-images-from-avi-when-framerate-is-not-integer your software MathMF is solving the problem (I have mentioned it in my answer below). – mrz Jul 05 '17 at 12:11

1 Answers1

5

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.

mrz
  • 11,686
  • 2
  • 25
  • 81
  • 1
    You need to evaluate numberImages = Length@Import[avifile, "Frames"]; only once before starting the Do loop, not inside of the latter. – Alexey Popkov Jul 06 '17 at 03:25
  • @Alexey Popkov: yes ... in my original code I did it ... I mixed it up ... thanks – mrz Jul 06 '17 at 08:05