Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to use Mathematica to create compressed .avi video files from image sequences. I read the documentation on .avi but couldn't find a solution. In the documentation it says:

  • Internal`$VideoEncodings gives a list of video codecs available on your computer system.
  • Commonly available codecs include "YUV", "H261", "H263", "JPEG", "Uncompressed", "Cinepak", and "MotionJPEG".

but none of these video encoding options effectively reduces the file size. When I install the latest version of QuickTime on my computer and use the applicable video encoding options, the exported .mov files are encoded. However, I would prefer to have .avi files due to compatibility reasons. If I check for available video encodings I get:

Internal`$VideoEncodings

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

I also have other ways to create .avi files using different software through Mathematica but I would love to have it the pure Mathematica way. I am using version 9.0.1. Are there any good alternatives to create a good quality video? I don't have the impression that the .mov files are of good quality...

Edit 24/07/2014

  • QuickTime version 7.7.5 (1680.95.13)
  • Mathematica version 9.0.1

Here is an example piece of code that I have created. It gives absolutely the same file size for each .avi encoding I use (note that I leave out one of the encoding methods since it conflicts with FileNameJoin):

engine = Import["ExampleData/CTengine.tiff"];
outDir = CreateDirectory[
   FileNameJoin[{NotebookDirectory[], "AviExport"}]];

Cases[Internal`$VideoEncodings, Except["DV/DVCPRO - NTSC"]]

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

ParallelMap[
  Export[FileNameJoin[{outDir, "engine" <> # <> ".mov"}], engine, 
    "VideoEncoding" -> #] &, 
  Cases[Internal`$VideoEncodings, Except["DV/DVCPRO - NTSC"]]];

ParallelMap[
  Export[FileNameJoin[{outDir, "engine" <> # <> ".avi"}], engine, 
    "VideoEncoding" -> #] &, 
  Cases[Internal`$VideoEncodings, Except["DV/DVCPRO - NTSC"]]];

Grid[Prepend[{#, N@FileByteCount[#]/1024^2} & /@ 
   FileNames["*mov", {outDir}], {"Filename", "File size [MB]"}], 
 Alignment -> Left]

mov files

TableForm[Prepend[{FileBaseName@#, N@FileByteCount[#]/1024^2} & /@ 
   FileNames["*avi", {outDir}], {".avi file", "File size [MB]"}]]

avi files

Thanks for any suggestions!

share|improve this question
1  
@Mr.Wizard, actually my library will import AVI files but not export them. –  Simon Woods Jul 22 at 16:00
    
@Simon "Bummer" as they say. :-/ –  Mr.Wizard Jul 22 at 16:02
    
@Mr.Wizard, annoyingly there is support in Media Foundation for an AVI media sink but only for Windows 8.1. –  Simon Woods Jul 24 at 11:53
    
g3kk0, just to be clear, are you saying that you get uncompressed AVI regardless of which codec you select? This is (obviously) incorrect behaviour - I suggest stating your OS and QuickTime version in the question so that others with the same setup can comment on whether they see the same problem. –  Simon Woods Jul 24 at 11:57
    
One thing strikes me as peculiar in this question: "I don't have the impression that the .mov files are of good quality." What do you mean by that? –  Mr.Wizard Jul 24 at 15:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.