Codecs list
Hello all
I am trying to run OpenCV for the first time. Sorry for stupid question. I need to grab images from camera and wright them in AVI file. I need to have an option: compression or not compressed.
When i am using (int)1 as a paremeter for VideoWriter.open(...) i have an exception, but after pressing "continue" video is recorded. the same with ('D', 'I', 'B', ' ')
Can you point me to list of codecs and\or how to get it from system.
All i found for the moment is this, but not all seems to work for me:
http://www.fourcc.org/codecs.php
https://msdn.microsoft.com/en-us/libr...
Basically, I need all allowed parameters for fourcc() function. dynamically or static.
UPDATE
If i am passing (-1), i have this codecs in drop down.
But even not all of them are not working. By the way, what is the codes of this codecs?
By "not working" i mean file is created, but frames are not recorded by write() function. File size is 0 byte.
UPDATE after pklab answer
First of all thank you for such detailed answer. Read my answers here.
OpenCV doesn't have a function to get the list of available codecs.
But how window with list of codecs (if you use -1 ) is working in this case?
But, it's really useful to programmatically get this list or you just need to know if a codec is available or to know its fourcc ?
Both. i just need to know "codec is available" "programmatically" to chose one. For example, app will have a list of preferences and automatically select codec to use.
This codec is native on Windows.
Yes, i am developing in Windows, but app CAN (have to) work in Linux. Can i "bring" codec with me in the file(dll)?
FFMPEG
I am developing commercial app. I found some articles, what i can not use it.
not compressed... did you mean
Yes. The idea is to gain speed. It is real time fail proof application: no frames should be missed.
I would suggest to install some 3rd....
I prefer to be portable. No installations is expected.
using codec=0
I have exception in debug doing this. It is catched somewhere and i don't see it when executing app outside visual studio. And recording is going well. It is normal?
Update with a bit of my code
here you can see simplification of my code. it is extraction of 3 functions
QString name = "File full path";
width = 800;
height = 400;
unsigned char* frame = raw RGB data, coming directly from IP camera;
//initialization : StartVideoFile(QString name, int width, int height)
Size frameSize(width, height);
VideoWriter* _recorder = new VideoWriter(name.toStdString(), -1, 20, frameSize, true);
Mat* _frame = new Mat(frameSize, CV_8UC3); //3 chanels, 8 bit per chanel
//record frames : AttachVideoFrame( unsigned char* frame)
_frame->data = frame;
_recorder->write(*_frame);
//finalization : CloseVideoFile()
_recorder->release();
If your files are not recorded, it could be that the dimensions are incorrect and not the codecs. The codecs of the dropdown menu are the ones supported for your system!
@StevenPuttemans Thank you for comment. But how comes? it is the same data stream. And how i can programmatically get this list myself. Not via VideoWriter class interface?
you will need to dive into the source code!
@StevenPuttemans Source code of OpenCV?
Yep! Take a look at the video modules!
:) thanks
wow ! how many points here.
.so
files on Win you have DLLs and cross platform and codecs is a challenge.About exception...are you using debug DLLs? try to catch the exception and report it here. You might enclose your code with:
@pklab Thank you for update.
why you are using
new
? If you are using C++ just declare objects like belowThan grab from your camera into the
frame
memory buffer and write the_frame
object (which is mapped over 'frame')