i checked for VP8 encoder on opencv but unfortenately it is not supported :(. About the framerate, yes, sometimes imput is a small subset of images (around 10 or 20), so on those cases they do not want 25fps, and will want to put 2fps for example. I checked the command "mencoder out.avi -ovc lavc -lavcopts vcodec=mpeg4:vqscale=4 -ffourcc DX50 -o comp.avi" and it worked, and maintained the framerate of the original video wherere it was 1 or 25 or 100. Strangely, when i converted with openCV using the same codec, it does not allow me to set 1fps. its weird. Thinking now, i have a last option, to compress each image before sending it as a videoframe, i found that higuiui.h header of opencv support encoding into memory, but i cannot find a single example where they use it. I think im having problems with the first parameter.
bool imencode( const string& ext,
const Mat& img,
vector<uchar>& buf,
const vector<int>& params=vector<int>());
//ext The file extension that defines the output format
//img The image to be written
//buf The output buffer; resized to fit the compressed image
//params The format-specific save parameters, encoded as pairs paramId 1, paramValue 1,
//paramId 2, paramValue 2, .... The following parameters are currently supported:
//• In the case of JPEG it can be a quality (CV IMWRITE JPEG QUALITY), from 0 to 100
//(the higher is the better), 95 by default.
//• In the case of PNG it can be the compression level (CV IMWRITE PNG COMPRESSION),
//from 0 to 9 (the higher value means smaller size and longer compression time), 3 by
//default.
//• In the case of PPM, PGM or PBM it can a binary format flag (CV IMWRITE PXM BINARY),
//0 or 1, 1 by default.
i tried to use it this way:
//frame is an IplImage*
vector<int> p;
p.push_back(CV_IMWRITE_JPEG_QUALITY);
p.push_back(10);
vector<unsigned char> buf;
cv::imencode("JPEG", frame, buf, p);
but i get error:
Main::Creating video (480x270)......
Output #0, avi, to 'out.avi':
Stream #0.0: Video: rawvideo, yuv420p, 480x270, q=2-31, 8294 kb/s, 90k tbn, 1 tbc
writing frame 0 from block... 2010:02:08 20:54:47
OpenCV Error: Unspecified error (could not find encoder for the specified extension) in imencode, file /home/neoideo/OpenCV-2.1.0/src/highgui/loadsave.cpp, line 409
terminate called after throwing an instance of 'cv::Exception'
what(): /home/neoideo/OpenCV-2.1.0/src/highgui/loadsave.cpp:409: error: (-2) could not find encoder for the specified extension in function imencode
i think im not using the parameters correctly, any help welcome, this can be the solution!
must it be realtime? not sure what you menat, the speed in realtime?
the goal is i need to integrate the compression into my c++ program, so it is one packed program only.
sorry for bad engliss