0
votes

I am trying to use videoWriter in Matlab 2013a on a Windows 7 64 bit machine. I also have Matlab 2009a installed (which could be the issue)

My code fails here:

    vid = VideoWriter('TestVideo');

This gives me the following error: Error using VideoWriter (line 240) Undefined variable "asyncio" or class "asyncio.Channel".

Now if I do this:

    vid = VideoWriter('TestVideo.mp4','MPEG-4');

I get this error: Error using VideoWriter (line 168) The specified profile is not valid.

I tried installing codecs, but that didn't help.

I read somewhere that someone had a similar problem, and it was due to a corrupt path and it could be caused by an older installation of Matlab (2007), but nothing about what was eventually done to fix it. I have tried to add the asyncio folder in the Matlab directory to the Matlab path, but again no luck. I have further tried to find out what videoWriter does regarding asyncio, but cannot find any clues in the code, and I honestly don't really know what asyncio is. Uninstalling Matlab 2009a is not an option.

So can anyone help me please?

BR Gorm

3

3 Answers

2
votes

You need to use the second way of invoking VideoWriter.... so doing:

vid = VideoWriter('TestVideo.mp4','MPEG-4');

However, you are getting this error:

Error using VideoWriter (line 168) The specified profile is not valid.

This is due to the fact that you probably don't have the MPEG-4 codecs installed on your computer. You can verify this by doing this in MATLAB:

profiles = VideoWriter.getProfiles()

Run the above code in the Command Prompt. You get a list of all possible profiles that you can use for writing a video to file using VideoWriter. For example, I'm using MATLAB R2013a on Mac OS and this is what I get:

>> profiles = VideoWriter.getProfiles()
  Summary of installed VideoWriter profiles:

          Name                                     Description                              
    ---------------- -----------------------------------------------------------------------
    Archival         Video file compression with JPEG 2000 codec with lossless mode enabled.
    Grayscale AVI    An AVI file with Grayscale Video Data
    Indexed AVI      An AVI file with Indexed Video Data
    MPEG-4           A MPEG-4 file with H.264 Compression
    Motion JPEG 2000 Video file compression with JPEG 2000 codec.
    Motion JPEG AVI  An AVI file with Motion JPEG compression
    Uncompressed AVI An AVI file with uncompressed RGB24 video data

If you don't see MPEG-4 on your list of profiles, then you currently don't have the profile installed. As such, you will have to use one of the provided profiles that MATLAB has for you.


Since you're running Windows, one suggestion I have is to install the Windows 7 Codec Pack suite: http://www.windows7codecs.com/. I know you said that when you installed codecs, it didn't work but you can try the above link if you haven't done it already.

The above website contains all of the codecs you would need to play video files in Windows. This will hopefully allow you to use VideoWriter once you install the codecs.

1
votes

So I found an answer to my own question. It was the path that was broken. Problem can be fixed easily by setting the Matlab search path to default.

0
votes

This is an old question, but I also wanted to add my two cents. What solved the problem for me was looking at my Windows version. Many companies have a Windows N version installed on their computers. These versions don't have all of the codecs and software, needed for playing and creating media files. So if you are using Matlab at work this might be the problem.

The fix is downloading the Windows Media Feature Pack for N Versions and to make sure that no other codec packs, like K-Lite are installed.