0

I'm writing a BlackBerry 10 application which decodes an H264 video stream (from a Parrot AR Drone) using ffmpeg and libx264. These libraries have both been compiled for BlackBerry QNX.

Here's my code:

av_register_all();
avcodec_register_all();
avformat_network_init();

printf("AV setup complete\n");

const char* drone_addr = "http://192.168.1.1:5555";
AVFormatContext* pFormatCtx = NULL;
AVInputFormat* pInputFormat = av_find_input_format("H264");

printf("Opening video feed from drone\n");

//THIS LINE FAILS 
int result = avformat_open_input(&pFormatCtx, drone_addr, pInputFormat, NULL); 

The last line fails with the error:

Malloc Check Failed: :../../dlist.c:1168

How can I fix this error or debug it further?

Update: The error only occurs when I supply pInputFormat to avformat_open_input. If I supply NULL I don't get an error. But for my app I must supply this parameter since it is not possible for ffmpeg to determine the video format from the feed alone.

donturner
  • 17,867
  • 8
  • 59
  • 81
  • did you try using "h264" is small caps ? `ffmpeg -formats` lists h264, and it is known to be rather picky. – SirDarius Aug 22 '13 at 20:17
  • Thanks, nice idea, unfortunately I still get the same error. `pInputFormat` is not null so I'm assuming that it's initialised correctly. – donturner Aug 22 '13 at 20:30
  • well, I guess you'll have to find a way to get a complete backtrace from the error. Do you have GDB or equivalent software at your disposal ? – SirDarius Aug 22 '13 at 20:35
  • I have gdb. Just trying to figure out how to compile x264 and ffmpeg with debug symbols. – donturner Aug 22 '13 at 20:45

2 Answers2

0

Try:

AVFormatContext* pFormatCtx = avformat_alloc_context();

Then

avformat_free_context(pFormatCtx);

ryyker
  • 22,849
  • 3
  • 43
  • 87
  • Thanks for the suggestion. Unfortunately that didn't work. According to the docs (http://ffmpeg.org/doxygen/trunk/group__lavf__decoding.html#ga10a404346c646e4ab58f4ed798baca32) you're allowed to specify a NULL pointer for the `AVFormatContext` to `avformat_open_input`. – donturner Aug 22 '13 at 20:10
0

I fixed this by adding the --enable-memalign-hack to the configure flags for ffmpeg. I narrowed the problem down to: libavutil/mem.c which includes some preprocessor defines for various memory handlers which led me to that configure flag.

Not sure if this is the right fix, or whether I'm setting myself up for problems later. Looks like someone else has had similar problems here: http://ffmpeg.org/pipermail/ffmpeg-devel/2013-February/138634.html

donturner
  • 17,867
  • 8
  • 59
  • 81