Message Boards Message Boards

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

Why Import .AVI does not show any frame?

Posted 10 years ago
POSTED BY: Marcelo De Cicco
20 Replies

Does anything come into Mathematica if you use just Import with two or three frames,
(example, Import["https://dl.dropboxusercontent.com/u/37906119/M20141102053738PET_1.avi", {"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
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?

Pieter,

I Think you gave a very good clue

POSTED BY: Marcelo De Cicco

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.

Pieter,

It is exactly what is happening

POSTED BY: Marcelo De Cicco

"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["https://dl.dropboxusercontent.com/u/37906119/M20141102_053738_PET_1.avi", "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 http://reference.wolfram.com/language/ref/format/AVI.html
show the use of various elements, including no element specified (which defaults to a count of frames).

POSTED BY: Bruce Miller

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["psintrowalk.mov", tst, "Quicktime", "FrameRate" -> 2]

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.

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:

https://dl.dropboxusercontent.com/u/37906119/M20141104_224225_PET_1.avi https://dl.dropboxusercontent.com/u/37906119/M20141104_234358_PET_1.avi https://dl.dropboxusercontent.com/u/37906119/M20141104_234358_PET_1P.jpg

POSTED BY: Marcelo De Cicco

Hi Bruce, Any news form the developers?

salute,

POSTED BY: Marcelo De Cicco

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

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

Import["C:\\Users\\decicco\\Desktop\\TestesCAptura\\M20141202_013032_\
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.

Attachments:
POSTED BY: Jim Baldwin

Baldwin,

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!!

Thanks!

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

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
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

Great!

POSTED BY: Marcelo De Cicco
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract