Message Boards Message Boards

20 Replies
1 Total Likes
View groups...
Share this post:

Why Import .AVI does not show any frame?

Posted 10 years ago

I tried Import a avi file but the frames do not appears. I use Math 10,running in windows 8, Asus, i7, 4 gb.

The manipulate runs, but no frames.

The link for the video:

POSTED BY: Marcelo De Cicco
20 Replies


POSTED BY: Marcelo De Cicco
Posted 10 years ago

All of the above that you mention and more: ImageMagick

But to keep all commands in the one place, I'd certainly run everything from within Mathematica.

POSTED BY: Jim Baldwin

Yes, sure I do.

Is that possible convert to jpegs and bmps?

Let me see if i get the whole picture, I have an video.avi, I use magik to convert all the frames in gifs (or jpegs, if possible), and then I use Mathematica to filter the converted frames, etc...

POSTED BY: Marcelo De Cicco


I have think about it, but I was trying using only Math, building a whole packet to video captures of meteors events. But your suggestions are awesome, i didnt know imagemagik, and it will be super for me as I use linux for hard work...

So my next steps will be taking frames before event, after, stacking them, applying some reduction noises etc, and using codes that I am discussing in another issue , as I have to use some (smart) edge detecting for stars, etc.. for capturing only similar things that behave as meteors, as the video above!!


POSTED BY: Marcelo De Cicco
Posted 10 years ago

As you probably know the Run command can be used to direct things (run external programs) from within Mathematica.

POSTED BY: Jim Baldwin

I tried a second approach, I imported the avi, and then export each frame as jpeg:

PET_1.avi", {"Frames", 4}];
Export["video1.jpg", %]

But, the jpeg image is blank, no image.

I need a algorithm that do an analyses in videos.avi, to calculate a final jpeg image: 1. stacking all the frames in one. 2. Reduction noises, etc, as we do in astrophotography.

The file M20141202013032\ PET_1.avi, is in the dropboxlink: Video link

POSTED BY: Marcelo De Cicco
Posted 10 years ago

If your main objective is to do the analysis in Mathematica, then you might consider using another program to get the individual frames and then import into Mathematica for the analysis. One such program is ImageMagick (which runs on multiple platforms) and the command line to convert the avi to a gif (from which Mathematica can import into individual frames) is something like the following at a DOS prompt (well, for Windows, that is):

convert -quiet M20141102_053738_PET_1.avi PET.gif

I was able to import your original .avi file and obtain 126 frames with the "object" showing up in frames 27 through 34. I found the ImageMagick command at

Convert avi to gif

The resulting gif with just frames 27 through 34 is attached.

POSTED BY: Jim Baldwin

I have a think about the issue, the pc where the camera ccv is linked and the videos are taken does not have Quicktime installed. Coud be this the problem?

POSTED BY: Marcelo De Cicco

Hi Bruce, Any news form the developers?


POSTED BY: Marcelo De Cicco

On this [page][1] is says:

" (Thanks to K.H. from Wolfram): Even on Windows, if QuickTime is installed, Mathematica uses the native QuickTime install (excluding added, third-party codecs) to import AVI files "

It is a remark from jan 2012. If still correct that would explain why you can not import a YUV coded AVI file on windows...

Pieter, Bruce,

I did the same as Pieter:

In[8]:= Internal`$VideoEncodings

Out[8]= {"Animação", "BMP", "Cinepak", "DVCPRO - PAL", "DV/DVCPRO - \
NTSC", "DV - PAL", "Elementos Gráficos", "Foto - JPEG", "H.261", \
"H.263", "JPEG 2000", "Motion JPEG A", "Motion JPEG B", "MPEG-4 \
Video", "Nenhum", "Planar RGB", "PNG", "Sorenson Video", "TGA", \
"TIFF", "Uncompressed", "Vídeo", "Vídeo Componente"}

Also there is no YUV, that UfoCapture encodes. And I have quicktime installed. The images are very black,with tiny scintillations points - stars. If is correct thatPieter says aboute third parties, how can we make math recognize YUV ?

Bruce have you tried seeing the movie with media player?

I uploaded more AVIS and JPEGS images to help our quest:

POSTED BY: Marcelo De Cicco

One last thing:

evaluating: Internal`$VideoEncodings

gives on my system:

{"Animation", "BMP", "Cinepak", "Component Video", "DVCPRO - PAL", \ "DV/DVCPRO - NTSC", "DV - PAL", "Graphics", "H.261", "H.263", "JPEG \ 2000", "Motion JPEG A", "Motion JPEG B", "MPEG-4 Video", "Photo - \ JPEG", "Planar RGB", "PNG", "Sorenson Video", "TGA", "TIFF", \ "Uncompressed", "Video"}

so mathematica does no see the YUV codec.

Bruce, Marcelo, The following code takes 9 frames of an AVI file and then exports it to a .mov file. Works fine with all my own AVI examples. It does not work with the 90mb YUV coded file. btw, the file plays fine on windows player but does not play on quicktime. Not the same YUV codec?? The video is quite black but when full screen on a 30inch monitor there is something very briefly flying from right to left. I checked also with M9 and YUV was already supported there but I can not make it work. No idea how to check if Mathematica sees the codec.

tst = Import["psintrowalk.avi", {"Frames", Range[9]}]; Export["", tst, "Quicktime", "FrameRate" -> 2]

"YUV" is an encoding Mathematica 10 should know.

I will download the AVI to a file and ask developers about what might be going on.

If it is supposed to be a black sky with a few tiny light pixels, could it be that the compression was enough to dilute the points of light. On my Mathematica 10.0.1 on MacOS 10.8.5, the animation from

Import["", "Animation"] 

is all black. (With 10.0.1 on Windows 7, the animation is all white. The last time I saw this contrast in an AVI file, the codec was not available on either machine.)

The examples at the bottom of
show the use of various elements, including no element specified (which defaults to a count of frames).

POSTED BY: Bruce Miller

extra note: If I use the Import["myvideo,avi", {"Frames", {2,8}]] option as mentioned by Bruce the frame numbers are returned as pictures (with my own testfiles)

This does not happen with the 90mb video of Marcelo. It returns only white pictures for list elements (while the content is mostly black) The encoding of Marcelo's file is YUV mathematica reports.


It is exactly what is happening

POSTED BY: Marcelo De Cicco


I Think you gave a very good clue

POSTED BY: Marcelo De Cicco

Hello Bruce and Marcelo,

I have the same problem in M10.0.1. When importing a AVI file it retruns something like {1,2,3 etc}. If these are the frame numbers then an export would generate the movie again. I tried Export["movie3", reftoimport, "QuickTime"]. Mathematica evaluates but the movie is showing 1 ,2 , 3 etc.

If I import the AVI file with Import["filename.avi", "VideoEncoding"] it shows different encodings for different AVI files (examples MJPG, BMP, Uncompressed]. All files return numbers when imported.

all files run fine on my Win7 64 system. including the Marcelo's very dark video. So I am also searching for a clue what is happening?

hi Bruce,

Nothing comes even trying one or two frames. And the video runs nicely in mediaplayer. The video plays on Smplayer - Opensuse distro, also. It is very dark, as it is a video from dark sky video camera, capturing a very fast event ( probably a meteor, I do not know yet), that I intend to filter the frames using Math. But first I need see the each frames... The program that capture the video is called UFOCAPTURE: And I am developing some methods to study meteors, using mathematica.

Is there another way to upload the video here? it has 87,2 mb.

I read this from the capture software:

" Video format setting

UFOCaptureV2 supports input video formats below. You can use some of which that the driver program of your capture hardware supports.
    resolution: 320x240 to 1920x1280
    frame rate: 10.0 fps to 60.0 fps
    internal input video encoding: UYUV, YUY2, I420, IYUV, YV12, DVSD 
UFOCaptureV2 can resize video images so that the pixel to be square.
    ex. input 720x480, 4:3 not true square pixel -> 640x480 4:3 true square pixel.
    This function requires high CPU performance, it is not recommended when CPU does not have enough power. 
    non-compressed AVI (recommend for scientific observation )
    highly-compressed WMV
    other AVI codecs which are install to your PC. ( no assurance ) 
Audio "
POSTED BY: Marcelo De Cicco

Does anything come into Mathematica if you use just Import with two or three frames,
(example, Import["", {"Frames", {2, 10}}])
or download it and open it in another app?

When I tried to download and open this in a web browser via Quicktime, nothing appeared.

Would you know what codec it uses? It might be a codec that our computers lack. (Codecs are not part of the AVI standard, so it is up to the creator of the AVI to use one the end users have.)

POSTED BY: Bruce Miller
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract