Merge pull request #5456 from sergiud:ffmpeg-capture-varying-frame-size
This commit is contained in:
commit
56e8827ce0
@ -750,9 +750,6 @@ bool CvCapture_FFMPEG::retrieveFrame(int, unsigned char** data, int* step, int*
|
|||||||
if( !video_st || !picture->data[0] )
|
if( !video_st || !picture->data[0] )
|
||||||
return false;
|
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 ||
|
if( img_convert_ctx == NULL ||
|
||||||
frame.width != video_st->codec->width ||
|
frame.width != video_st->codec->width ||
|
||||||
frame.height != video_st->codec->height )
|
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)
|
if (img_convert_ctx == NULL)
|
||||||
return false;//CV_Error(0, "Cannot initialize the conversion context!");
|
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(
|
sws_scale(
|
||||||
img_convert_ctx,
|
img_convert_ctx,
|
||||||
picture->data,
|
picture->data,
|
||||||
|
Loading…
Reference in New Issue
Block a user