CvVideoWriter get current fourcc
Using class cv::VideoWriter
I can specify CV_FOURCC_PROMPT
(which is -1) as fourcc
parameter in constructor or its open
function, in which case "Open Codec Selection Dialog" will be opened and user will select one of installed codecs. My application will perform video recording several times and I want to avoid asking user the same question more than once.
Is there a way to retrieve user selected codec from already opened cv::VideoWriter
instance and re-use it as fourcc
parameter for other instances?
take a look at this
@sturkmen Thank you, but that code uses
VideoCapture
object, which I don't have in my software, as well as any otheropencv
input object. My images are generated by another part of software not made with opencv. Are you saying that I need to open first generatedavi
file for input just to read its codec? What if I need to create second output in another thread while first one is not closed yet?so, you're using opencv only for saving video ? that might be a bad idea. still:
if you know the codec before, you can pass it to the VideoWriter via VideoWriter::fourcc() (in other words, you don't have to use the prompt, if you don't want to.)
unfortunately, codecs are installed per machine, so you can never rely on any special codec available on an unknown box.
'M','J','P','G'
for codec, and.avi
for container.@berak thank you for your answer. No I am using opencv also for other purposes (creating
mat
objects and processing them) but I get my buffers not from any opencv input object. Writing withVideoWriter
is quick and temp solution, in future versionsffmpeg
will be used directly. Still it is not clear from your answer how to obtain codec selected by user when I passed -1 initially - and that is what my question. I know that I don't have to use prompt and can specify a codec by self, but I want to use prompt - but only first time and for next recording I want to re-use codec that a user has once selectedunfortunately, there is no way retrieving the codec from VideoWriter.
also note, that the choice box is a builtin part of VFW, and only available on windows.
@berak Thank you, I know that, that's why this question is tagged with
windows