1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Framework for dynamic videoio backends, FFmpeg and GStreamer plugins

This commit is contained in:
Maksim Shabunin
2019-01-14 13:33:38 +03:00
parent 8bde6aea4b
commit 9702987209
64 changed files with 2330 additions and 1528 deletions
+23 -27
View File
@@ -785,7 +785,6 @@ static int LockCallBack(void **mutex, AVLockOp op)
}
static ImplMutex _mutex;
static bool _initialized = false;
class AutoLock
{
@@ -814,49 +813,45 @@ static void ffmpeg_log_callback(void *ptr, int level, const char *fmt, va_list v
class InternalFFMpegRegister
{
public:
InternalFFMpegRegister()
static void init()
{
AutoLock lock(_mutex);
if (!_initialized)
{
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 13, 0)
avformat_network_init();
#endif
static InternalFFMpegRegister instance;
}
InternalFFMpegRegister()
{
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 13, 0)
avformat_network_init();
#endif
/* register all codecs, demux and protocols */
av_register_all();
/* register all codecs, demux and protocols */
av_register_all();
/* register a callback function for synchronization */
av_lockmgr_register(&LockCallBack);
/* register a callback function for synchronization */
av_lockmgr_register(&LockCallBack);
#ifndef NO_GETENV
char* debug_option = getenv("OPENCV_FFMPEG_DEBUG");
if (debug_option != NULL)
{
av_log_set_level(AV_LOG_VERBOSE);
av_log_set_callback(ffmpeg_log_callback);
}
else
char* debug_option = getenv("OPENCV_FFMPEG_DEBUG");
if (debug_option != NULL)
{
av_log_set_level(AV_LOG_VERBOSE);
av_log_set_callback(ffmpeg_log_callback);
}
else
#endif
{
av_log_set_level(AV_LOG_ERROR);
}
_initialized = true;
{
av_log_set_level(AV_LOG_ERROR);
}
}
~InternalFFMpegRegister()
{
_initialized = false;
av_lockmgr_register(NULL);
}
};
static InternalFFMpegRegister _init;
bool CvCapture_FFMPEG::open( const char* _filename )
{
InternalFFMpegRegister::init();
AutoLock lock(_mutex);
unsigned i;
bool valid = false;
@@ -1997,6 +1992,7 @@ static inline void cv_ff_codec_tag_dump(const AVCodecTag *const *tags)
bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
double fps, int width, int height, bool is_color )
{
InternalFFMpegRegister::init();
CV_CODEC_ID codec_id = CV_CODEC(CODEC_ID_NONE);
int err, codec_pix_fmt;
double bitrate_scale = 1;