[Libav-user] A very mysterious question about FFMpeg encoding.

Matthew Einhorn moiein2000 at gmail.com
Fri Sep 23 20:01:26 CEST 2011


On Thu, Sep 22, 2011 at 5:02 PM, Denis <info at denisgottardello.it> wrote:

> **
>
> > You need to show the source of your data. How do you get the frames from
> a
>
> > webcam, does it come in packets? RGB data? that's the code you should
> show.
>
> > The problem that I'm seeing is that you're using an avio context when you
>
> > don't actually intend to write data with it to a file. Just take the
> webcam
>
> > frame data call avcodec_encode_video and that function writes it to a
>
> > buffer. I'm not sure why you're making the all these avio calls. I
> suggest
>
> > you also look at the headers for avcodec_encode_video.
>
>   The source code is below. Can you explain me which are the steps that I
> must follow?
>
>
> ....


>  if (ExternalFrame) cvShowImage("Frame", frame);
>
> QImage Image(frame->width, frame->height, QImage::Format_RGB888);
>
> const unsigned char *data= NULL;
>
> data= (unsigned char*)(frame->imageData);
>
> Image= QImage(data, frame->width, frame->height, frame->widthStep, QImage
> ::Format_RGB888);
>
> if (DoStart) emit SendNewImage(Image);
>
>  AVFrame *pAVFrame= avcodec_alloc_frame();
>
> uint8_t *pBuffer= (uint8_t*)malloc(avpicture_get_size(PIX_FMT_YUV420P,
> Width, Height)); {
>
> avpicture_fill((AVPicture*)pAVFrame, pBuffer, PIX_FMT_YUV420P, Width,
> Height);
>
> IplImageToAVFrame(frame, pAVFrame, Width, Height, PIX_FMT_YUV420P);
>
> pAVFrame->pts= Frames;
>
> int OutSize= avcodec_encode_video(pCodecCtx, pOutBuffer, BYTEPIC,
> pAVFrame);
>
> The avcodec_encode_video call above encodes the picture in pAVFrame into
the pOutBuffer buffer. If I understood the question correctly this is what
you're looking for. If that's not what you need, can you elaborate a bit
more?

Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20110923/e4e1f000/attachment.html>


More information about the Libav-user mailing list