How to get videoWriter working with directShow

asked 2019-02-13 07:16:09 -0600

Ikarus79 gravatar image

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

edit retag flag offensive close merge delete

Comments

Have you try to use constant defined here?

LBerger gravatar imageLBerger ( 2019-02-13 07:21:23 -0600 )edit
1

@Ikarus79 imho, you're right about it, the DSHOW can only be used for VideoCapture.

how to select a specific codec

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 gravatar imageberak ( 2019-02-13 07:57:12 -0600 )edit

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

Ikarus79 gravatar imageIkarus79 ( 2019-02-13 08:25:34 -0600 )edit

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 gravatar imageberak ( 2019-02-13 08:31:13 -0600 )edit
1

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

Ikarus79 gravatar imageIkarus79 ( 2019-02-13 09:42:55 -0600 )edit

how MSMF is choosing the encoder?

that's a good question ! (unfortunately, i've no idea, sorry)

berak gravatar imageberak ( 2019-02-13 10:10:52 -0600 )edit