6

I am using OpenCV to display a video my code is as

#include<opencv2/highgui.hpp>
#include<cv.h>
#include<opencv/cv.hpp>
#include<opencv2/opencv.hpp>
#include<cvaux.h>
#include<cxcore.h>
#include<stdio.h>
#include<highgui.h>
#include<stdlib.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
int main( int argc, char ** argv )
{
CvCapture* capture;
cvNamedWindow( "video", CV_WINDOW_AUTOSIZE ); 
capture = cvCreateFileCapture("/home/vaibhav/program/c/w.avi");
IplImage* frame;
while(1){
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "video", frame );
char c = cvWaitKey(33);
if( c == 27 ) break;
}

cvReleaseCapture( &capture );

cvDestroyWindow( "Webcam" );

return 0; }

The program compiles but it gives error when try to run it

I am using Ubuntu 12.04 and Eclipse

warning: Error opening file (/home/vaibhav/opencv/modules/highgui/src/cap_ffmpeg_impl.hpp:553)
P. Camilleri
  • 12,664
  • 7
  • 41
  • 76
user3309272
  • 67
  • 1
  • 1
  • 4

8 Answers8

15

to clear up some confusion here:

the error means, that it could not find or open your Video file. (either file not found, or codec not present)

"/home/vaibhav/opencv/modules/highgui/src/cap_ffmpeg_impl.hpp:553" is just the location of the code, where the error is thrown.

(and please, don't use the deprecated c-api any longer, they stopped developing it like 5 years ago, switch over to the c++ one. )

berak
  • 39,159
  • 9
  • 91
  • 89
3

I had the same problem. Very annoying (opencv 2.4.9). But what worked for me was passing the absolute file name (avi or mpeg), i.e whole path.

E.g.:

char* fileName = "D:/myVideos/video.avi"
...
VideoCapture capture(fileName );
AbcAeffchen
  • 14,400
  • 15
  • 47
  • 66
mykey
  • 1,943
  • 19
  • 13
  • 1
    The author of the question if on Ubuntu, and already pass full path, so the answer does not seems to fit to his problem – tomsoft Sep 30 '14 at 11:54
  • I'm using Windows 7 64 bit with Visual Studio 2013. This answer solved my problem. Thanks! – JohnSaps Jun 29 '16 at 08:53
2

If using absolute path, add double slash to path as below.

data = cv2.VideoCapture('C:\Data\MyVideo.mp4')

data.isOpened()

Out[11]: False

data = cv2.VideoCapture('C:\\\Data\\\MyVideo.mp4')

data.isOpened()

Out[13]: True

Luís Cruz
  • 14,780
  • 16
  • 68
  • 100
1

I had the same problem, and I did two things (I'm using Python 2.7.9 on Windows 10):

First, add this folder to your Path variable:

C:\opencv\sources\3rdparty\ffmpeg\

And this file opencv_ffmpeg300.dll must have the correct OpenCV version. For example, for me it's 3.0.0, so you need to change it for yourself.

Next, make sure to add an extra backslash slash in your video path:

video_capture = cv2.VideoCapture ('C:\Temp\\bouncingBall.avi')

Python has some special characters, so if there's only one backslash, it would interpret it differently and thus throw an error. You can see more here:

https://docs.python.org/2.0/ref/strings.html

Hence the double backslash.

Anyway, hope this helps!

Kaya311
  • 545
  • 2
  • 9
  • 21
1

After having the same issue, I added one more header, opencv/ml.h, which is for machine learning. With this header and the Path variable C:\opencv\sources\3rdparty\ffmpeg\ your code works on my machine.

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
Cloud Cho
  • 1,594
  • 19
  • 22
0

I also got the same error if the video is not present in the folder. So, just put the video at a place where you don't need to give a long path which you are doing currently (just to see that your program can work). For example, i have placed my video just outside the "source folder", so i just write capture = cvCreateFileCapture("video.avi");

skm
  • 5,015
  • 8
  • 43
  • 104
0

I'm facing the same issue, but the problem is I used the wrong resolution.

change

rtsp://admin:admin@192.168.1.58:554/h264/video.sdp?camera=13

to default solved it. (without indicating the resolution parameter)

rtsp://admin:admin@192.168.1.58:554/h264/video.sdp

BTW Device: EVO-05 Mini

JustWe
  • 4,250
  • 3
  • 39
  • 90
0

I just used double quotes instead of single quotes using the entire video path and it worked for me! (on windows)