Problem of running mex file that compiled with FFmpeg library

2 次查看(过去 30 天)
I am developing on a 64-bit Windows 7 with Matlab 2012a with compiler of Visual Studio 10+Microsoft SDK 7.1, I am trying to convert the written C++ to mex, where function of the C++ code is using the FFmpeg library to decode a video stream and passing the image frame into Matlab. The mex is successfully compiled, however when run the mex, it gives the following error:
Invalid MEX-file '\FFMPEG\test2.mexw64':The specified procedure could not be found.
Initially, I am thinking it was the problem of the DLL files, but after using the 'dependency walker' to check all the DLL, they seems to be fine and all the search path is included, by now I have no idea of what the problem is, is there anything I have missed out when compiling the C++ file? The following is part of the 'test2' C++ code:
#include "mex.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <math.h>
// OpenCV
#include <opencv2/opencv.hpp>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv/cxcore.h>
// FFmpeg
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[])
{
//IplImage *img;
if (nrhs != 0)
{
mexErrMsgTxt("Do not give input arguments.");
}
if (nlhs != 0)
{
mexErrMsgTxt("Do not give output arguments.");
}
// Register all formats and codecs
av_register_all();
avcodec_register_all();
avformat_network_init();
}

采纳的回答

Neil Huang
Neil Huang 2014-3-7
The solution requires few modifications of the compiler options 'mexopts.bat'
1. Setting the imported FFmpeg libraries to work with the /OPT:REF option
2. Also by switching to multi-threaded debug mode allows me to run the mex files, through modifying the /MD to /MTd

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by