[Libav-user] 答复: Errors when creating a C++ object (with a C API) in FFmpeg filter

R n flynewdream at hotmail.com
Thu Sep 15 08:48:02 EEST 2016

Also, it looks like I cannot use the libopencv in ffmpeg even if I enable it, because they have limited function support for openCV.

Another problem is that some basic openCV functions/types, like Mat, in my library cannot be recognized when I am executing FFmpeg. Looks like the openCV lib is not included in my library? I tried to play with the CMakeList.txt of my library with openCV setting but still cannot solve this problem.

Any suggestions? Thanks.

发件人: Libav-user <libav-user-bounces at ffmpeg.org> 代表 R n <flynewdream at hotmail.com>
发送时间: 2016年9月14日 3:30
收件人: libav-user at ffmpeg.org
主题: [Libav-user] Errors when creating a C++ object (with a C API) in FFmpeg filter

Dear all,

First, thanks for this mail list which helped me solve the compilation problem.

I wrote a C++ class using openCV as well as a C wrapper/API. I am now using it in FFmpeg filter. In the filter, I create a pointer to an object which is generated by calling the C API (The API actually returns "new myCPPclass()"). It can compile but the execution of the program "stop" around the place where the pointer is created. "Stop" here means that there is no printed info anymore (I print out the execution steps) but the response of the computer to my typing is wired. Looks like the memory has some problems.

In FFmpeg, people use av_malloc... , but it is not encouraged to first malloc the memory to the C++ object using malloc and then cast its type to a C++ class.

Did I miss anything? Thanks a lot.

My code looks like the following:

1. C++ class:

class myCPPclass {





2. C API:

typedef myCPPclass myCPPclass;

extern "C" myCPPclass* myCPPclass_new(abc) {

  return new myCPPclass(abc);


3. FFmpeg filter (in C):

myCPPclass* ptr = myCPPclass_new(abc);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160915/6225228e/attachment.html>

More information about the Libav-user mailing list