AVI Files Result in a Black Screen When Viewed

Updated Jan 8, 2019

Reported In

Software

  • Vision Development Module

Driver

  • Vision Acquisition Software
  • NI-IMAQ

Issue Details

I have created certain AVI files that are taller than they are wide or of equal height and width.  For some reason, they are not being read successfully in either LabVIEW or Windows Media Player.  They play just fine on VideoLAN Client (VLC), but for the previous two players, all that shows up is a blank (black) screen for the length of the AVI file.

Solution

There is a simple solution. Compress the file with any of the other compression methods available (DV Video, Cinepak Codec, Intel IYUV codec, Microsoft RLE, Microsoft Video) and you will be able to open the file without the black screen.  Another simple solution would just be to ensure that your AVI files have an even height value of pixels.

If you would like to see an example of this in action, please use the code below to create an AVI file, and read that written file with the Read AVI File.vi located in NI Example Finder under Toolkits and Modules»Vision»Files.  The written AVI file should appear as a blank gray video file if working, and will be black if it cannot be read.

The working compressed file will look as follows:

The non-working compressed AVI file will appear like this:

Additional Information

This problem can be associated with how the video file is sized as well as how it is compressed.  For an MJPEG compressed video, if the pixel height is an odd number and is greater than or equal to the video width (both of which must be greater than a pixel value of 291), the file will display as a black video.

What causes this is that the MJPEG file compression format results in files being created that cannot be read by our software unless the pixel height is a multiple of two or the file size is under a certain limit.

If you are interested in more information about how AVI files are stored, please see the link in the Related Links section.