Restore tomaka17's idea on how to ensure av_free_packet is called. Fixes a memory leak I left