[FFmpeg-user] Bad dst image pointers
Diederick C. Niehorster
dcnieho at gmail.com
Mon Jul 12 15:24:17 EEST 2021
av_frame_alloc alone is not enough, you also need to allocate the
memory for the image data, e.g. using av_image_alloc
see e.g. https://ffmpeg.org/doxygen/trunk/doc_2examples_2decoding_encoding_8c-example.html
On Mon, Jul 12, 2021 at 1:09 PM 李罗 <bruce_lee0815 at 163.com> wrote:
>
>
> I have already connected and opened camera successfully. But I can not transfor frame data from AV_PIX_FMT_YUVJ422P to AV_PIX_FMT_BGR24 after decoding. As I call method sws_scale, 'bad dst iamge pointers' shows up. Any help will be appreciate, my code:
>
>
> AVFrame* pFrame, * pFrameYUV;
> pFrame = av_frame_alloc();
> pFrameYUV = av_frame_alloc();
>
> int ret, got_picture;
> AVPacket* packet = (AVPacket*)av_malloc(sizeof(AVPacket));
>
> struct SwsContext* img_convert_ctx;
> img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, AV_PIX_FMT_BGR24, SWS_BICUBIC, NULL, NULL, NULL);
>
> if (av_read_frame(pFormatCtx, packet) >= 0) {
> if (packet->stream_index == videoindex) {
> ret = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, packet);
> if (ret < 0) {
> return NULL;
> }
> if (got_picture) {
> sws_scale(img_convert_ctx, (const unsigned char* const*)pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameYUV->data, pFrameYUV->linesize);
> }
> }
> av_free_packet(packet);
> }
>
> | |
> 李罗
> |
> |
> 邮箱bruce_lee0815 at 163.com
> |
>
> 签名由 网易邮箱大师 定制
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-user
mailing list