Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

VideoCapture Bug on Linux using Video without a Codec

Hi All,

there is a known bug in the VideoCapture ffmpeg module. It occurs while loading videos without a codec: http://code.opencv.org/issues/1915

I had some time now to debug this bug and found the issue in:

CvCapture_FFMPEG::grabFrame()

In the function

avcodec_decode_video2(video_st->codec, picture, &got_picture, &packet);

the AVFrame picture get set. But after

av_free_packet (&packet);

I get: "error: Cannot access memory at address..." for picture.data[0] which leads to a segmentation fault later in the function sws_scale().

I can encode this video with a video codec using ffmpeg or whatever and I get no segmentation fault (memory in picture.data[0] can still be accessed).

Of course there is an easy fix for this bug: Simply comment out / delete

av_free_packet (&packet);

This is working fine for me. Now I can process videos with and without codecs. But I am not sure if this will lead to memory issues if av_free_packet gets not called. Is there anybody who is familiar with FFmpeg and can help me here?

Thanks a lot!

VideoCapture Bug on Linux using Video without a Codec

Hi All,

there is a known bug in the VideoCapture ffmpeg module. It occurs while loading videos without a codec: http://code.opencv.org/issues/1915

I had some time now to debug this bug and found the issue in:

CvCapture_FFMPEG::grabFrame()

In the function

avcodec_decode_video2(video_st->codec, picture, &got_picture, &packet);

the AVFrame picture get set. But after

av_free_packet (&packet);

I get: "error: Cannot access memory at address..." for picture.data[0] which leads to a segmentation fault later in the function sws_scale().

I can encode this video with a video codec using ffmpeg or whatever and I get no segmentation fault (memory in picture.data[0] can still be accessed).

Of course there is an easy fix for this bug: Simply comment out / delete

av_free_packet (&packet);

This is working fine for me. Now I can process videos with and without codecs. But I am not sure if this will lead to memory issues if av_free_packet gets not called. Is there anybody who is familiar with FFmpeg and can help me here?

Thanks a lot!