Merge pull request #5456 from sergiud:ffmpeg-capture-varying-frame-size

pull/5467/head
Alexander Alekhin 9 years ago
commit 56e8827ce0
  1. 12
      modules/videoio/src/cap_ffmpeg_impl.hpp

@ -750,9 +750,6 @@ bool CvCapture_FFMPEG::retrieveFrame(int, unsigned char** data, int* step, int*
if( !video_st || !picture->data[0] )
return false;
avpicture_fill((AVPicture*)&rgb_picture, rgb_picture.data[0], AV_PIX_FMT_RGB24,
video_st->codec->width, video_st->codec->height);
if( img_convert_ctx == NULL ||
frame.width != video_st->codec->width ||
frame.height != video_st->codec->height )
@ -775,8 +772,17 @@ bool CvCapture_FFMPEG::retrieveFrame(int, unsigned char** data, int* step, int*
if (img_convert_ctx == NULL)
return false;//CV_Error(0, "Cannot initialize the conversion context!");
rgb_picture.data[0] = (uint8_t*)realloc(rgb_picture.data[0],
avpicture_get_size( AV_PIX_FMT_BGR24,
video_st->codec->width, video_st->codec->height ));
frame.data = rgb_picture.data[0];
}
avpicture_fill((AVPicture*)&rgb_picture, rgb_picture.data[0], AV_PIX_FMT_RGB24,
video_st->codec->width, video_st->codec->height);
frame.step = rgb_picture.linesize[0];
sws_scale(
img_convert_ctx,
picture->data,

Loading…
Cancel
Save