[Libav-user] Encoding H263+ video

David Longest david.longest at apx-labs.com
Tue Jan 15 15:27:23 CET 2013


> Please post your source code, if possible - the minimal crashing example. Make sure you use the latest version of fffmpeg libraries. What is your platform and compiler?
>
> BR,
> Alex

I have found what my problem was. As the following code sample would show, I was using av_malloc to allocate an AVPacket on the heap. While I called av_init_packet to initialize the fields of the AVPacket struct, that function does not zero out the data or size field. Changing this to av_mallocz instead fixed the issue I was running into.

AVFrame* testFrame;
AVCodecContext* context;
/*
I set up the frame and context in here.
*/
int validPacket = 0;
AVPacket* packet = reinterpret_cast<AVPacket*>(av_malloc(sizeof(AVPacket)));
av_init_packet(packet);
int error = avcodec_encode_video2(context, packet, testFrame, &validPacket);
if (validPacket)
{
                // TODO: save out packet data.
                av_free_packet(packet);
}
av_free(packet);

Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130115/2f1eba72/attachment.html>


More information about the Libav-user mailing list