MATLAB: Can I read a video file in MATLAB R2015b (32 bit), but not in R2017b

3264bitcinepakcodecMATLAB

I have an AVI file that I can successfully read in 32 bit releases of MATLAB, such as R2015b.
However, when I try to read the file in R2017b, I get the error message shown below:
>> v = VideoReader('myfile.avi')
Error using VideoReader/init (line 619)
The file requires the following codec(s) to be installed on your system:
cvid
Error in VideoReader (line 172)
obj.init(fileName);
How can I read this video into MATLAB R2017b?

Best Answer

As the error message notes, this is due to the fact that MATLAB is unable to access the 'cvid' codec, also known as Cinepak.
This codec is a 32 bit codec, and is thus only accessible to 32 bit applications.
As a troubleshooting step, it is helpful to verify that it is reproduced by Windows Media Player. Typically, 64 bit Windows installations will have both versions of Windows Media Player. If the 32 bit version can read this file, but the 64 bit version cannot, it is likely related to this particular codec.
Note that the 32 bit version of Windows Media Player can be found in 'C:\Program Files (x86)', while the 64 bit version is in 'C:\Program Files'.
As a workaround, the user can convert the video to a format that is readable from both 32 bit and 64 bit MATLAB. The code snippet below shows one way to do this:
v = VideoReader(source);
v2 = VideoWriter(dest);
open(v2)
while v.hasFrame
currFrame = readFrame(v);
writeVideo(v2,currFrame);
end
close(v2);