8
$\begingroup$

Here's a list of images:

images = Table[ExampleData[i], {i, ExampleData["TestImage"]}];

And according to the reference "Export exports a list of graphics, images, or arbitrary expressions, taking each element to be an animation frame." This is on the reference page for .avi. However,

Export["animation.avi", images]

causes this:

Export::errelem: "The Export element !(\"ImageList\") contains a malformed data structure and could not be exported to !(\"AVI\") format."

What's the problem?

(Export["film.avi", ListAnimate[images]] works, but I want to know why the above doesn't work...)

$\endgroup$
  • 1
    $\begingroup$ In light of Sjore's answer it is interesting why Export["film.avi", ListAnimate[images]] does work? $\endgroup$ – Ajasja May 15 '12 at 20:42
  • $\begingroup$ Hm... perhaps not. What happens when we export ListAnimate? Basically it's like exporting screenshots of a manipulate-window. All these screenshots have the same size, color channels and so on. $\endgroup$ – C. E. May 15 '12 at 22:01
9
$\begingroup$

The images have different color spaces, dimensions and image channels. How would you make a movie from that?

ImageColorSpace /@ images // Union

(*  ==> {"Grayscale", "RGB"}   *)

ImageDimensions /@ images // Union

(*  ==> {{256, 256}, {512, 512}, {1024, 1024}}  *)

ImageChannels /@ images // Union

(*   ==> {1, 3}  *)

You'd have to convert them all to the same format.

images2 =  ImageResize[ColorConvert[#, "Grayscale"], {256, 256}] & /@ images

will do just that. You can now export it:

Export["animation.avi", images2, "FrameRate" -> 1]

enter image description here

$\endgroup$
  • 3
    $\begingroup$ It might be worth adding a note that one can use ConformImages to do the conversion in version 10 $\endgroup$ – Simon Woods Sep 21 '14 at 10:12
  • $\begingroup$ A powerful function, indeed. Good find! $\endgroup$ – Sjoerd C. de Vries Sep 21 '14 at 12:35
4
$\begingroup$

I would guess this is because the images are all of different sizes. For a concrete answer about this, contact technical support at support@wolfram.com with your license number.

In meantime you can create the animation using a Manipulate:

Export["animation.avi", 
 Manipulate[images[[i]], {i, 1, Length@images, 1}]]
$\endgroup$

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.