[Libav-user] QImage(RGB32) to AVFrame(RGB32)

Valeriy Shtoma shtomavaleriy at gmail.com
Wed Apr 18 17:00:55 EEST 2018


Thanks for your reply!

Okay, it’s clear. For now I have another code:
AVFrame *frame = av_frame_alloc();
AVBufferRef *buffer = av_buffer_create(img->bits(), img->sizeInBytes(),
		                                       [](void *pOpaque, uint8_t *pData) {
			                                       pData = nullptr;
				const auto p = static_cast<QImage *>(pOpaque);
								delete p;
		                                       }, img, 0);
frame->buf[0] = buffer;
frame->data[0] = buffer->data;

But QImage::bits() always returned nullptr.
buffer.data = ‘\0'

Kind Regards,
Valeriy V Shtoma

> On Apr 18, 2018, at 16:54, salsaman <salsaman at gmail.com> wrote:
> 
> Actually av_image_alloc() should set it for you so you shouldn't need to set it yourself.
> 
> 
> Gabriel.
> 
> 
> http://lives-video.com
> https://www.openhub.net/accounts/salsaman
> 
> On Wed, Apr 18, 2018 at 10:49 AM, salsaman <salsaman at gmail.com> wrote:
> linesize should be w * 4 for ARGB I think.
> 
> Gabriel.
> 
> 
> http://lives-video.com
> https://www.openhub.net/accounts/salsaman
> 
> On Wed, Apr 18, 2018 at 2:04 AM, Valeriy Shtoma <shtomavaleriy at gmail.com> wrote:
> Hi to all dear developers,
> 
> I want to convert QImage to AVFrame and than push it to
> filter. But when I pushed AVFrame, I got an error:
> 
>  [in @ 0x11c71c200] Changing frame properties on the fly
> is not supported by all filters.
> 
> and than
> 
>  [libx264 @ 0x10ea52c00] Input picture width (640) is greater
>  than stride (0)
> 
> But in this case my picture 1280x720...
> I know, that my code wrong(not correct pointers and linesize)
> What I’m doing wrong?
> 
> My code:
> 
> Varian 1:
> AV_PIX_FMT_ARGB or AV_PIX_FMT_RGB32
> 
> QImage img = ...;
>  AVFrame *frame = av_frame_alloc();
>  avpicture_fill((AVPicture*)frame, img.bits(), AV_PIX_FMT_ARGB,
>  img.width(), img.height());
> 
> Variant 2:
> AVFrame *frame = av_frame_alloc();
> av_image_alloc(frame->data, frame->linesize, w, h, AV_PIX_FMT_ARGB, 1);
> frame->width = w;
> frame->height = h;
> frame->format = AV_PIX_FMT_ARGB;
> frame->linesize[0] = w;
> av_image_fill_arrays(frame->data, frame->linesize, (uint8_t*)img.bits(),
>  AV_PIX_FMT_ARGB, w, h, 1);
> 
> Thanks for attention. :)
> 
> Kind Regards,
> Valeriy V Shtoma
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
> 
> 
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user



More information about the Libav-user mailing list