Cannot open some video files in OpenCV 2.4.13 for Java

asked 2016-10-16 09:42:39 -0600

SniFFzoR gravatar image

updated 2016-10-16 12:57:18 -0600

Hi,

I have a problem regarding opening video files. I recently created an .avi-file from a bunch of images that I had taken from a camera. When I tried to open this using the following line of code,

VideoCapture vidCap = new VideoCapture("C:/somePathOnC/fileName.avi");

everything worked fine. However, when I try another video file, for instance the example video from this example. The video file in that example is called bouncingBall.avi. This, however, won't work. The program does not open up the video file, and no errors are shown.

The same happens with another video file I took from my IP-camera. The program I used to record the file, iSpy, saved the file as .mp4. Since this didn't work, I tried to convert it to .avi with different "codecs". I have so far tried all of the settings that the converter program offers. These are:

  • H.264 /MPEG-4 AVC video format
  • AVI-audio-video interleaved
  • XViD-movie
  • Lossless uncompressed AVI
  • AVI with DV-coded

Also, please not that I've tried to have both of the files in the same folder, but it still didn't work.

So now, I'm out of ideas on how to solve this. I have done some search about an issue regarding FFMPEG, but I do not understand how to resolve that.

Thank you.

edit retag flag offensive close merge delete

Comments

I don't know java but check video path and try to print video properties :

vidCap.get(CV_CAP_PROP_FPS);
vidCap.get(CV_CAP_PROP_FOURCC);
vidCap get(CV_CAP_PROP_FRAME_WIDTH);
vidCap.get(CV_CAP_PROP_FRAME_HEIGHT);

and compare those values with C:/somePathOnC/fileName.avi

in C++ to write CODECS name I use :

string fourcc_str = format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
LBerger gravatar imageLBerger ( 2016-10-16 11:16:55 -0600 )edit

I guess you mean that I should check those values for one video file that does work, and compare it with another one that doesn't? Have I understood that correctly?

SniFFzoR gravatar imageSniFFzoR ( 2016-10-16 12:05:09 -0600 )edit

yes it's not an answer but may be a way to understand your problem...

LBerger gravatar imageLBerger ( 2016-10-16 12:08:49 -0600 )edit

Okay, so I did what I thought that you meant and ended up with this:

vidCap.get(CV_CAP_PROP_FPS) = 4 vidCap.get(CV_CAP_PROP_FOURCC) = 5.41215044E8 vidCap.get(CV_CAP_PROP_FRAME_WIDTH) = 640 vidCap.get(CV_CAP_PROP_FRAME_HEIGHT) = 480

For the other video that doesn't work, I get 0.0 on all of the values.

SniFFzoR gravatar imageSniFFzoR ( 2016-10-16 12:14:50 -0600 )edit

Check vidCap : if (vidCap.isOpened()) { .... } else { cout<< "cannot openned"; }

Can use an int instead of double int x=vidCap.get(CV_CAP_PROP_FOURCC);

LBerger gravatar imageLBerger ( 2016-10-16 12:25:56 -0600 )edit

I already have that piece of code in place, and for the video file that doesn't work, I always enter the else-block in your example.I have also edited the original post, just to notify that I've tried to have both of the files in the same folder, but without luck.

SniFFzoR gravatar imageSniFFzoR ( 2016-10-16 12:56:38 -0600 )edit

What is fourcc code value in an int variable? read this post too

LBerger gravatar imageLBerger ( 2016-10-16 13:45:03 -0600 )edit

FourCC = 541215044 if I cast it to an integer. What is that value anyway?

SniFFzoR gravatar imageSniFFzoR ( 2016-10-16 16:20:07 -0600 )edit

in hexa it 541215044 = 0x20424944 = ' BID' codecs is DIB.

video C:/somePathOnC/fileName.avi use a DIB codec.

LBerger gravatar imageLBerger ( 2016-10-17 01:41:01 -0600 )edit