mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
videoio(plugins): support VideoCaptureParameters, CAPTURE_API_VERSION=1
- example: ffmpeg
This commit is contained in:
@@ -456,7 +456,7 @@ static AVRational _opencv_ffmpeg_get_sample_aspect_ratio(AVStream *stream)
|
||||
|
||||
struct CvCapture_FFMPEG
|
||||
{
|
||||
bool open( const char* filename );
|
||||
bool open(const char* filename, const VideoCaptureParameters& params);
|
||||
void close();
|
||||
|
||||
double getProperty(int) const;
|
||||
@@ -857,7 +857,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool CvCapture_FFMPEG::open( const char* _filename )
|
||||
bool CvCapture_FFMPEG::open(const char* _filename, const VideoCaptureParameters& params)
|
||||
{
|
||||
InternalFFMpegRegister::init();
|
||||
AutoLock lock(_mutex);
|
||||
@@ -866,6 +866,29 @@ bool CvCapture_FFMPEG::open( const char* _filename )
|
||||
|
||||
close();
|
||||
|
||||
if (!params.empty())
|
||||
{
|
||||
if (params.has(CAP_PROP_FORMAT))
|
||||
{
|
||||
int value = params.get<int>(CAP_PROP_FORMAT);
|
||||
if (value == -1)
|
||||
{
|
||||
CV_LOG_INFO(NULL, "VIDEOIO/FFMPEG: enabled demuxer only mode: '" << (_filename ? _filename : "<NULL>") << "'");
|
||||
rawMode = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_LOG_ERROR(NULL, "VIDEOIO/FFMPEG: CAP_PROP_FORMAT parameter value is invalid/unsupported: " << value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (params.warnUnusedParameters())
|
||||
{
|
||||
CV_LOG_ERROR(NULL, "VIDEOIO/FFMPEG: unsupported parameters in .open(), see logger INFO channel for details");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_AV_INTERRUPT_CALLBACK
|
||||
/* interrupt callback */
|
||||
interrupt_metadata.timeout_after_ms = LIBAVFORMAT_INTERRUPT_OPEN_TIMEOUT_MS;
|
||||
@@ -2424,13 +2447,15 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
|
||||
|
||||
|
||||
|
||||
CvCapture_FFMPEG* cvCreateFileCapture_FFMPEG( const char* filename )
|
||||
static
|
||||
CvCapture_FFMPEG* cvCreateFileCaptureWithParams_FFMPEG(const char* filename, const VideoCaptureParameters& params)
|
||||
{
|
||||
// FIXIT: remove unsafe malloc() approach
|
||||
CvCapture_FFMPEG* capture = (CvCapture_FFMPEG*)malloc(sizeof(*capture));
|
||||
if (!capture)
|
||||
return 0;
|
||||
capture->init();
|
||||
if( capture->open( filename ))
|
||||
if (capture->open(filename, params))
|
||||
return capture;
|
||||
|
||||
capture->close();
|
||||
@@ -2438,7 +2463,6 @@ CvCapture_FFMPEG* cvCreateFileCapture_FFMPEG( const char* filename )
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void cvReleaseCapture_FFMPEG(CvCapture_FFMPEG** capture)
|
||||
{
|
||||
if( capture && *capture )
|
||||
|
||||
Reference in New Issue
Block a user