Ask Your Question

nklatt's profile - activity

2015-01-25 15:47:23 -0500 received badge  Famous Question (source)
2014-05-27 07:37:14 -0500 received badge  Notable Question (source)
2013-12-29 17:36:48 -0500 received badge  Popular Question (source)
2013-05-08 10:45:33 -0500 commented answer VideoWriter fourcc=-1 works but CV_FOURCC('C','R','A','M') does not

(This isn't actually the answer - that can be found in the comments to the original post - but I want to be sure Mr Puttemans receives the points for helping solve my problem.)

2013-05-08 10:44:04 -0500 received badge  Scholar (source)
2013-05-08 10:43:09 -0500 commented question VideoWriter fourcc=-1 works but CV_FOURCC('C','R','A','M') does not

This is the warning message I mentioned above:

x264vfw [warning]: Few frames probably would be lost. Ways to fix this:

x264vfw [warning]: - if you use VirtualDub or its fork than you can enable 'VirtualDub Hack' option

x264vfw [warning]: - you can enable 'File' output mode

x264vfw [warning]: - you can enable 'Zero Latency' option

2013-05-08 10:42:27 -0500 commented question VideoWriter fourcc=-1 works but CV_FOURCC('C','R','A','M') does not

Well, I first tried just downloading the DivX codec and it, like the others, worked from the -1 select but not when specified directly in the code. So, I grabbed the K-lite Basic pack but it only has decoders so I grabbed the 22MB Mega pack and it has some encoders. And... one of them (X264) even works! It doesn't impact my throughput at all and it generates small files. The only issues are relatively minor: it pops up a warning about frames being lost* and a message is logged to the terminal, "Could not find encoder for codec id 28: Encoder not found". Still, much better than the -1 select menu.

I would love to know why it was such a struggle but I am happy to have a workable solution for now.

Thanks again.

2013-05-07 12:19:32 -0500 commented question VideoWriter fourcc=-1 works but CV_FOURCC('C','R','A','M') does not
  • Options I get in the dropdown when I pass in -1 for the codec:
  • Microsoft RLE which doesn't work at all
  • Microsoft Video 1 generates a CRAM file
  • Intel IYUV codec generates an IYUV file
  • Intel IYUV codec generates an IYUV file (yes, it's in the list twice)
  • Cinepak Codec by Radius generates a CVID file but everything slows to 6 FPS
  • Full Frames (Uncompressed) generates a file that works but I can't tell the type
2013-05-07 12:16:49 -0500 commented question VideoWriter fourcc=-1 works but CV_FOURCC('C','R','A','M') does not

Okay, I've installed VLC and ran through some codecs (DIVX, IYUV, CRAM, MSVC, WHAM, CVID, PIM1, MJPG, MP42, DIV3, U263, I263, FLV1) but nothing seems to have changed. One thing I was surprised by is I still have the same small list of options* when I pass -1 in as the codec; is there something I need to do in my build or OS environment to tell the program where to find the codecs for encoding?

One other thing I realized is I am able to generate a playable video file by passing in CVID. Unfortunately, that particular codec, whether chosen from the dropdown or specified by the code, causes my throughput to drop from 20 FPS to 6. But, it implies the code works, I just need to figure out how to get it to work with other codecs.

Thanks a lot for the help.

2013-05-07 10:36:00 -0500 received badge  Student (source)
2013-05-07 08:37:50 -0500 commented answer VideoWriter fourcc=-1 works but CV_FOURCC('C','R','A','M') does not

(Please see my comment, above - thanks.)

2013-05-07 08:36:47 -0500 commented question VideoWriter fourcc=-1 works but CV_FOURCC('C','R','A','M') does not

Yeah, I did try those for that same reason but no joy. I used CRAM first since that is what is embedded in the working video file, as you can see in the first image - easier to see if you view it full-size.

I also have the same result with IYUV which is a better-regarded codec but it's the same deal - it works if I select it from the dropdown but not if I direct VideoWriter to use that codec from the code.

I feel like I must be doing something more basic wrong like improperly mixing C and C++ interfaces or something, maybe?

2013-05-06 11:29:42 -0500 received badge  Editor (source)
2013-05-06 10:02:04 -0500 asked a question VideoWriter fourcc=-1 works but CV_FOURCC('C','R','A','M') does not

Howdy,

I am using the VideoWriter class to capture video from a camera to a file. I am doing CV in the code as well, of course, but am adding video capture to help troubleshoot and optimize.

I am able to capture the video if I pass the magic number "-1" as the fourcc parameter, like so:

outputVideo = new cv::VideoWriter(outputVideo_name, -1, 20, img_rgb.size(), true);

I select "Microsoft Video 1" from the dropdown and it generates a video file using the CRAM codec.

However, if I replace that "-1" with "CV_FOURCC('C','R','A','M')", it says it's capturing video but the file is always 6kB and does not play. Using MSVC or WHAM produces similar results.

I am running on Windows 7 with a PS3 Eye camera using the CL-Eye driver and OpenCV 2.4.1, compiled with Eclipse and MinGW's g++ (GCC) 4.5.2.

Any ideas on what I might be doing wrong?

Thanks,

Nathan

=====

EDIT: Images showing binary differences between now-working and working generated video files:

image description

(Here there be zeros.)

image description