opencv如何对视频进行编解码
2014-03-11 13:58
316 查看
VideoCapture captRefrnc(“Megamind.avi")
||
\/
/*cap.cpp文件*/
CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
{
CvCapture * result = 0;
if (! result)/*首先调用FFMPEG解码*/
result = cvCreateFileCapture_FFMPEG_proxy (filename);
#ifdef HAVE_XINE
if (! result)
result = cvCreateFileCapture_XINE (filename);
#endif
#ifdef HAVE_GSTREAMER
if (! result)
result = cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename);
#endif
#ifdef HAVE_QUICKTIME
if (! result)
result = cvCreateFileCapture_QT (filename);
#endif
#ifdef HAVE_AVFOUNDATION
if (! result)
result = cvCreateFileCapture_AVFoundation (filename);
#endif
#ifdef HAVE_OPENNI
if (! result)
result = cvCreateFileCapture_OpenNI (filename);
#endif
if (! result)
result = cvCreateFileCapture_Images (filename);
return result;
}
其中:当用FFMPEG解码时: result = cvCreateFileCapture_FFMPEG_proxy (filename);
||
\/
static void icvInitFFMPEG(void)
{
static int ffmpegInitialized = 0;
if( !ffmpegInitialized )
{
#if defined WIN32 || defined _WIN32
const char* module_name = "opencv_ffmpeg"
CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
"_64"
#endif
".dll";
/*显示的是module_name = "opencv_ffmpeg243.dll"*/
static HMODULE icvFFOpenCV = LoadLibrary( module_name );/*装入opencv_ffmpeg243.dll库*/
if( icvFFOpenCV )
{
icvCreateFileCapture_FFMPEG_p =
(CvCreateFileCapture_Plugin)GetProcAddress(icvFFOpenCV, "cvCreateFileCapture_FFMPEG");/*定位到库的函数,下同!*/
icvReleaseCapture_FFMPEG_p =
(CvReleaseCapture_Plugin)GetProcAddress(icvFFOpenCV, "cvReleaseCapture_FFMPEG");
icvGrabFrame_FFMPEG_p =
(CvGrabFrame_Plugin)GetProcAddress(icvFFOpenCV, "cvGrabFrame_FFMPEG");
icvRetrieveFrame_FFMPEG_p =
(CvRetrieveFrame_Plugin)GetProcAddress(icvFFOpenCV, "cvRetrieveFrame_FFMPEG");
icvSetCaptureProperty_FFMPEG_p =
(CvSetCaptureProperty_Plugin)GetProcAddress(icvFFOpenCV, "cvSetCaptureProperty_FFMPEG");
icvGetCaptureProperty_FFMPEG_p =
(CvGetCaptureProperty_Plugin)GetProcAddress(icvFFOpenCV, "cvGetCaptureProperty_FFMPEG");
icvCreateVideoWriter_FFMPEG_p =
(CvCreateVideoWriter_Plugin)GetProcAddress(icvFFOpenCV, "cvCreateVideoWriter_FFMPEG");
icvReleaseVideoWriter_FFMPEG_p =
(CvReleaseVideoWriter_Plugin)GetProcAddress(icvFFOpenCV, "cvReleaseVideoWriter_FFMPEG");
icvWriteFrame_FFMPEG_p =
(CvWriteFrame_Plugin)GetProcAddress(icvFFOpenCV, "cvWriteFrame_FFMPEG");
总结:说明opencv用ffmpeg对视频编解码,用opencv_ffmpeg243.dll库的,而不是静态链接。如果用这个库编解码视频,必须拷贝这个dll。
||
\/
/*cap.cpp文件*/
CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
{
CvCapture * result = 0;
if (! result)/*首先调用FFMPEG解码*/
result = cvCreateFileCapture_FFMPEG_proxy (filename);
#ifdef HAVE_XINE
if (! result)
result = cvCreateFileCapture_XINE (filename);
#endif
#ifdef HAVE_GSTREAMER
if (! result)
result = cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename);
#endif
#ifdef HAVE_QUICKTIME
if (! result)
result = cvCreateFileCapture_QT (filename);
#endif
#ifdef HAVE_AVFOUNDATION
if (! result)
result = cvCreateFileCapture_AVFoundation (filename);
#endif
#ifdef HAVE_OPENNI
if (! result)
result = cvCreateFileCapture_OpenNI (filename);
#endif
if (! result)
result = cvCreateFileCapture_Images (filename);
return result;
}
其中:当用FFMPEG解码时: result = cvCreateFileCapture_FFMPEG_proxy (filename);
||
\/
static void icvInitFFMPEG(void)
{
static int ffmpegInitialized = 0;
if( !ffmpegInitialized )
{
#if defined WIN32 || defined _WIN32
const char* module_name = "opencv_ffmpeg"
CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
"_64"
#endif
".dll";
/*显示的是module_name = "opencv_ffmpeg243.dll"*/
static HMODULE icvFFOpenCV = LoadLibrary( module_name );/*装入opencv_ffmpeg243.dll库*/
if( icvFFOpenCV )
{
icvCreateFileCapture_FFMPEG_p =
(CvCreateFileCapture_Plugin)GetProcAddress(icvFFOpenCV, "cvCreateFileCapture_FFMPEG");/*定位到库的函数,下同!*/
icvReleaseCapture_FFMPEG_p =
(CvReleaseCapture_Plugin)GetProcAddress(icvFFOpenCV, "cvReleaseCapture_FFMPEG");
icvGrabFrame_FFMPEG_p =
(CvGrabFrame_Plugin)GetProcAddress(icvFFOpenCV, "cvGrabFrame_FFMPEG");
icvRetrieveFrame_FFMPEG_p =
(CvRetrieveFrame_Plugin)GetProcAddress(icvFFOpenCV, "cvRetrieveFrame_FFMPEG");
icvSetCaptureProperty_FFMPEG_p =
(CvSetCaptureProperty_Plugin)GetProcAddress(icvFFOpenCV, "cvSetCaptureProperty_FFMPEG");
icvGetCaptureProperty_FFMPEG_p =
(CvGetCaptureProperty_Plugin)GetProcAddress(icvFFOpenCV, "cvGetCaptureProperty_FFMPEG");
icvCreateVideoWriter_FFMPEG_p =
(CvCreateVideoWriter_Plugin)GetProcAddress(icvFFOpenCV, "cvCreateVideoWriter_FFMPEG");
icvReleaseVideoWriter_FFMPEG_p =
(CvReleaseVideoWriter_Plugin)GetProcAddress(icvFFOpenCV, "cvReleaseVideoWriter_FFMPEG");
icvWriteFrame_FFMPEG_p =
(CvWriteFrame_Plugin)GetProcAddress(icvFFOpenCV, "cvWriteFrame_FFMPEG");
总结:说明opencv用ffmpeg对视频编解码,用opencv_ffmpeg243.dll库的,而不是静态链接。如果用这个库编解码视频,必须拷贝这个dll。
相关文章推荐
- 音视频编解码问题:javaCV如何快速进行音频预处理和解复用编解码(基于javaCV-FFMPEG)
- 音视频编解码问题:javaCV如何快速进行音频预处理和解复用编解码(基于javaCV-FFMPEG)
- 利用ffmpeg和opencv进行视频的解码播放
- 利用ffmpeg和opencv进行视频的解码播放
- 如何通过MediaCodec来进行视频解码后再编码
- 利用ffmpeg和opencv进行视频的解码播放
- 利用ffmpeg和opencv进行视频的解码播放
- ffmpeg和Opencv结合进行视频解码播放
- iOS开发技巧之:如何在iOS平台上对一个视频进行解码和显示
- 利用ffmpeg和opencv进行视频的解码播放
- Opencv3.0-python的那些事儿:(九)、Opencv关于如何读取大量视频帧进行处理的方法
- 利用Hadoop和opencv进行处理视频的原理
- Python+OpenCV进行视频中人脸检测
- 如何解决opencv读取avi视频文件一闪而过
- 高效率视频播放: 如何使用3D API 进行视频的高质量回放(1)
- 【视频处理工程】8、关于DXVA视频解码硬件加速(1):Decoder如何调用IAMVideoAccelerator接口
- 使用 ffmpeg 进行网络推流:拉流->解封装->解码->处理原始数据(音频、视频)->编码->编码->推流
- 如何解决opencv读取avi视频文件一闪而过
- 如何配置Windows Media Service进行视频直播
- opencv中检测视频内容是否变化,并且能够进行人脸检测。