Thats not how AVPackets are initilaized, please see how other encoders do it, one way is with ff_alloc_packet2()