5

I'm desperately attempting to load a video file in OpenCV in Python (on OSX Lion) using the following code:

> import cv
> capture = cv.CaptureFromFile("in.avi")

However, i only get the following warning:

> WARNING: Couldn't read movie file in.avi

There is no explanation as to what the problem is (it can't find the file, wrong codec, etc). As far as Google is concerned I'm the only one in the universe getting this exact message in OpenCV.

I've read the 'codec compatibility docs' here and made sure to convert the video to the correct codec using mencode, but it still doesn't work.

Any ideas as to what I'm doing wrong?

2
  • have you tried using the full path? if the in.avi isn't in the current working directory of the script, then that will be a problem the way it is written. Commented Feb 22, 2012 at 14:23
  • That was exactly it! In my case it needed to be: /Users/lauge/Desktop/video.mov Commented Feb 22, 2012 at 14:36

2 Answers 2

10

Answer: See my comment - Wrong path.

Sign up to request clarification or add additional context in comments.

3 Comments

Same here. I don't get it why this method needs absolute path.
i think this is a problem with the mac os version... the same code runs perfectly on my ubuntu machine but crashes on my macbook
Ideally someone could commit a patch and add #import os ... path = os.path.abspath(os.path.expanduser(path))
0

Alternatively, support home folders and replace relative paths to absolute ones using

#import os
...
path = os.path.abspath(os.path.expanduser(path))

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.