0

I'm working with a program, which I need to document and review, but which I did not write, nor did anyone I can easily reach. One of the problems I've run into is that it is supposed to read and work with .avi files, but every time I try, it fails. The file is an avi converted from an MTS format. The computer seems to think that it is an avi file, and it runs it without incident, but I don't know why the cvCaptureFromAVI is having trouble.

The function cvCaptureFromAVI simply returns null. I can't seem to get any deeper in the code to see what in cvCaptureFromAVI is causing the error, and I haven't been able to get any error information about why it won't read the file.

Bill
  • 698
  • 1
  • 5
  • 22
  • avi is just a container, chances are high, that you haven't got the codec to decompress it on your machine – berak May 10 '13 at 14:47
  • I recently pulled down avi videos I found online to test, and they also failed. So I'm not sure it's a problem with ffmpeg conversion. – Bill May 10 '13 at 14:51
  • maybe your program is not finding the video file. Check the path are you supplying to open the video capture. try using / instead of \ in the path. – Alexey May 10 '13 at 14:54
  • Also to rule out the possibility of file corruption or find not found, you can create a simple opencv application, to check whether you are able to play that file or not. You may want to cv::VideoCapture for it. Also on windows will need to use double slash("\\") for folder separator. Following link may be of help http://stackoverflow.com/questions/16185456/how-to-play-and-detect-an-object-using-captured-video-in-background-subtractor-m/16186105#16186105 – praks411 May 10 '13 at 15:00
  • Actually the program is designed to use a filePicker to select the avi file. But even if I circumvent that and give it a direct path (which works in explorer, and I can view the video) it doesn't load, even if I try with both single and double-slash. One of the other problems is that I'm not entirely sure how much of this code I'm allowed to change. I'm supposed to be assessing and evaluating it. So I'm a bit cautious about making significant code changes. – Bill May 10 '13 at 15:30
  • For Windows, install Xvid Codec – user3497324 Jul 02 '15 at 20:02

1 Answers1

0

I was struggling with this problem for two days! If you've double checked all other possible causes (file is in correct directory and inside your code the path to that file is in correct format) and still cvCaptureFromAVI returns null, the problem is your computer codecs. I suggest you installing K-Lite Codec Pack. Remember to restart your computer if you are using Windows.

Ali Salehi
  • 1,003
  • 8
  • 19