How to get videoWriter working with directShow
Hi,
The documentation of videoWriter in openCV >= 4.0.0 stats clearly:
On Windows FFMPEG or MSWF or DSHOW is used;
The Problem is that in videoio_registry.cpp the directshow backend gets discarded because mode is only: MODE_CAPTURE_BY_INDEX
and line 277 in videoio_registry.cpp applies:
if (info.mode & MODE_WRITER)
result.push_back(info);
My question is: Is the documentation wrong? Or in case it is correct, how to use the videoWriter and how to select a specific codec in particular?
tnx
Have you try to use constant defined here?
@Ikarus79 imho, you're right about it, the DSHOW can only be used for VideoCapture.
that's probably the man pain point here. while the underlying directshow graph is clearly able to write video files, codecs have to get registered individually, per machine, and thus it's not reliable, if they are available on your box or not by default. (you'd also have to select them by guid, and write com code for that, it's 20 years too late for that, imho)
please also note, that the DSHOW backend is "on the way out", it might be entirely replaced by MSMF in the near future.
@berak, thanks for verification. I didn't dive too deep in the implementation if the videoWriter yet. Is there a chance to get it working with DSHOW in the future?
quite unlikely. rather the whole DSHOW backend might be removed in the very near future.
is there any special reason, you need this one ?
@berak I switched now to MSMF and it works like charm. I have noticed that H264 is the default codec used by this api. I have several H264 codecs installed, leadtools for example, where I have a licence for the encoder. Leadtools comes with a direct show interface, that's why I was focused on the DSHOW first. With H264 encoder you have always the licencing issue. However, any idea/hint for me how MSMF is choosing the encoder? Thank for your support.
that's a good question ! (unfortunately, i've no idea, sorry)