[Libav-user] Encoding H263+ video

Alex Cohn alexcohn at netvision.net.il
Tue Jan 15 16:02:26 CET 2013

On Tue, Jan 15, 2013 at 4:27 PM, David Longest
<david.longest at apx-labs.com> wrote:
> 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.

There is little advantage in allocation AVPacket in the heap. In the
“decoding_encoding.c” example, the packet structure is placed on stack
and reused during encoding; but for each frame it is re-initialized

    pkt.data = NULL;    // packet data will be allocated by the encoder
    pkt.size = 0;

Anyways, it's good that you succeeded to resolve your problem.


More information about the Libav-user mailing list