ffmpeg: move packet deallocation into write_frame