Ask Your Question

Mikl's profile - activity

2017-09-21 07:52:33 -0500 received badge  Famous Question (source)
2017-06-01 13:31:46 -0500 received badge  Notable Question (source)
2017-04-11 05:10:31 -0500 received badge  Popular Question (source)
2016-09-13 01:34:54 -0500 received badge  Enthusiast
2016-09-12 05:16:03 -0500 commented question 'I', 'Y', 'U', 'V' exception

@StevenPuttemans You mean throw away because of content, but not wrong data format? It this case you are right. Sorry for misunderstanding. It can be garbage on a screen on first frames. Not really worries me now. I need to start recording at least something first.

2016-09-12 05:11:08 -0500 commented question 'M', 'R', 'L', 'E' codec recording 0 bytes

@StevenPuttemans Not inside this class. It is a library and have no interface window to display anything. But the copy if the same data is visualized and looks fine (except of colors are wrong, but i know the reason and it is for later). So, i am SURE, what data is correct.

2016-09-12 01:46:30 -0500 commented question 'I', 'Y', 'U', 'V' exception

@pklab The reason i started this question, you was not able to help me in my previous one.It is simplified version. Only one question.But i see you doing the same. I am asking about shape, you answering about color. :) I have exception on first frame because of "this is NOT safe@"? And i do not agree with StevenPuttemans. I was expected to have answer "ignore it" from JavaScript programmer, but not from c++. Sorry.

2016-09-09 09:06:36 -0500 commented question 'M', 'R', 'L', 'E' codec recording 0 bytes

@StevenPuttemans Blank, but not empty.:)

2016-09-09 09:04:55 -0500 commented question 'I', 'Y', 'U', 'V' exception

@StevenPuttemans Frame is correct. So, you advice is "ignore it"?

2016-09-09 01:52:36 -0500 asked a question 'I', 'Y', 'U', 'V' exception

Hello, I am recording video using IYUV codec. It is present in my system, because i can see it when using -1 for FOURCC

image description

But first time i want to record frame i have an exception

image description

This is happening only at first frame and only when i run it in Visual Studio (2015). If i press "Continue" everything is going well. After this recording is going without any problems. If i run application outside of Visual Studio nothing visible is happening.

I don`t think, what it is normal behavior. Can you help me please, what i am doing wrong and how to fix it.

I am using binaries, compiled myself in VS2015 from opencv-3.1.0 source. Maybe i need to configure "cmake" or VS project in special way?

source code

unsigned char* frame;//rgb raw data
int width = 800;
int height= 400;

Size frameSize(width, height);
VideoWriter recorder(name.toStdString(), CV_FOURCC('I', 'Y', 'U', 'V'), 20, frameSize, true);
Mat _frame(frameSize, CV_8UC3); = frame;
_recorder.write(_frame); <-line of exception



The same is happening during playback, using VideoCapture

2016-09-08 10:20:08 -0500 asked a question 'M', 'R', 'L', 'E' codec recording 0 bytes

Hello, I am recording video like this

unsigned char* frame;//rgb raw data
int width = 800;
int height= 400;

Size frameSize(width, height);
VideoWriter recorder(name.toStdString(), CV_FOURCC('M', 'R', 'L', 'E'), 20, frameSize, true);
Mat _frame(frameSize, CV_8UC3); = frame;


But no frames is recorded. File size is 0. Can you help me to find out what i am doing wrong, please.


I am using binaries, compiled myself in VS2015 from opencv-3.1.0 source. Maybe i need to configure "cmake" or VS project in special way?

2016-08-31 06:49:43 -0500 commented question Codecs list


  1. yes. char pointer is a frame buffer and pointed memory contains an image
  2. C++
  3. exactly this is making problem. when i have objects in H file, i need to include "opencv2\opencv.hpp". But main project, where i am including "MyWriter", also expecting to have "opencv2\opencv.hpp". but i will not make 20 copies of the same file only to make compiler happy.
  4. project is designed. it is always something to improve. but i will not make any big changes.
  5. my current problem is exception. i can not catch it. i don`t see it if i run app outside of visual studio.
2016-08-31 05:13:13 -0500 commented question Codecs list

@StevenPuttemans I am not making new every time. reusing the same object. releasing at the end.

2016-08-31 04:15:04 -0500 commented question Codecs list

:) ok. but both work yes? and i will solve my problem when i will switch? exception will disrepair?

2016-08-31 02:04:23 -0500 commented question Codecs list
  • It is a different between new and object declaration on functional level for OpenCV? My app is designed as library and it handy for me like this. I can have only pointer to external classes in header file and including realization only in cpp. Like this i can include my library without need to include opencv2\opencv.hpp in main project.
    • I can not grab anything inside of frame buffer. Data is coming by char pointer.
    • I can update my question, if you need full listing.
2016-08-30 04:51:38 -0500 commented answer Codecs list

when i am using 'M','J','P','G' and streaming RGB, video file is empty. What can be a problem?

2016-08-30 04:50:15 -0500 received badge  Scholar (source)
2016-08-30 02:33:47 -0500 commented question Codecs list

@pklab Thank you for update.

  • As you can see on bottom answer of, You might have a problem here.
  • And i can not catch it. I see it only when visual studio is stopping app.
2016-08-30 02:25:37 -0500 commented question Add subtitles to video

@Eduardo I need .srt. I don`t need to burn text. It is a video "metadata" and will be reused later. But can i keep it in the same video file?

2016-08-26 07:18:28 -0500 commented question Add subtitles to video

Ok. Thanks. Do you know what i need to use? Maybe i can ADD extra library?

2016-08-26 06:41:58 -0500 commented question Add subtitles to video

No, i mean embedding subtitles as text in the container

2016-08-26 03:44:37 -0500 asked a question Add subtitles to video


Can i add subtitles to video file, using OpenCV?

2016-08-26 01:41:29 -0500 received badge  Supporter (source)
2016-08-24 09:37:08 -0500 commented question Codecs list

:) thanks

2016-08-24 09:02:53 -0500 commented question Codecs list

@StevenPuttemans Source code of OpenCV?

2016-08-24 08:46:33 -0500 commented question Codecs list

@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?

2016-08-24 07:52:58 -0500 received badge  Editor (source)
2016-08-24 07:47:08 -0500 asked a question 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 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:

Basically, I need all allowed parameters for fourcc() function. dynamically or static.


If i am passing (-1), i have this codecs in drop down. image description

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)?


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;

//finalization : CloseVideoFile()