video: add a constructor with API preference parameter for VideoWriter#8920
video: add a constructor with API preference parameter for VideoWriter#8920opencv-pushbot merged 1 commit intoopencv:masterfrom
Conversation
edacebc to
379b76d
Compare
| */ | ||
| CVAPI(CvVideoWriter*) cvCreateVideoWriterWithPreference(int api, const char* filename, int fourcc, | ||
| double fps, CvSize frame_size, | ||
| int is_color CV_DEFAULT(1)); |
There was a problem hiding this comment.
Probably we should not add new exported cv* functions. Please make it local "static".
There was a problem hiding this comment.
I've moved it to the precomp.hpp where other similar functions are declared.
379b76d to
f419b00
Compare
modules/videoio/src/cap.cpp
Outdated
| default: | ||
| //exit if the specified API is unavaliable | ||
| if (apiPreference != CV_CAP_ANY) break; | ||
| case(CV_CAP_FFMPEG): |
There was a problem hiding this comment.
BTW, Why "case" values are in brackets?
There was a problem hiding this comment.
Don't know, just a habit.
|
Looks good to me. Well done! 👍 |
| { | ||
| CV_INSTRUMENT_REGION() | ||
|
|
||
| if (isOpened()) release(); |
There was a problem hiding this comment.
We should propagate apiPreference to this constructor too.
| CvVideoWriter *result = 0; | ||
|
|
||
| if(!fourcc || !fps) | ||
| TRY_OPEN(result, cvCreateVideoWriter_Images(filename)) |
There was a problem hiding this comment.
Maybe we could define additional API IDs for built-in MotionJPEG and Images backends? Or maybe we should add new set of IDs for VideoWriter specifically: WRI_ANY, WRI_FFMPEG, etc.? What do you think?
There was a problem hiding this comment.
I've defined CAP_OCV_MJPEG and we already have CAP_IMAGES.
modules/videoio/src/cap.cpp
Outdated
| default: | ||
| //exit if the specified API is unavaliable | ||
| if (apiPreference != CV_CAP_ANY) break; | ||
| case(CV_CAP_FFMPEG): |
There was a problem hiding this comment.
In my opinion wrapping whole case blocks into #ifdef..#endif will look more clean:
#ifdef HAVE_FFMPEG
case CV_CAP_FFMPEG:
TRY_OPEN(result, cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color))
if (apiPreference != CV_CAP_ANY) break;
#endif
#ifdef HAVE_VFW
case CV_CAP_VFW:
TRY_OPEN(result, cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, is_color))
if (apiPreference != CV_CAP_ANY) break;
#endiff419b00 to
df18768
Compare
df18768 to
f1c16f4
Compare
|
👍 |
resolves #8859