Sunday, April 12, 2015

Ubuntu Matlab: Error using VideoFileReader/setup Could not open the specified file.

In order to read video file using vision.VideoFileReader object, you need to initialize it:

video_source = vision.VideoFileReader('test.avi')

Now, to access a (next) frame of the video, you need to run the following command:

frame  = step(videoSource);

If you are doing it for the first time after fresh Matlab installation, you will probably run into the following error:

Error using VideoFileReader/setup 
Could not open the specified file.

This happens because Matlab is unable to find the correct codec to decode the video file. To solve this problem, follow these steps:


  • Install ubuntu-restricted-extras
    • sudo apt-get install ubuntu-restricted-extras
  • Install Gstreamer
    • sudo add-apt-repository ppa:gstreamer-developers/ppa
    • sudo apt-get update
    • sudo apt-get install gstreamer0.10-tools gstreamer-tools gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-bad
  • Install gstreamer0.10-ffmpeg 
    • sudo add-apt-repository ppa:mc3man/trusty-media
    • sudo apt-get update 
    • sudo apt-get install gstreamer0.10-ffmpeg
Restart the Matlab and it should work just fine!

Enjoy!