avconv: merge two loops in output_packet().