Support decoding of ImageJ png in avi.

Fixes ticket #3916.
avformat/segment: Use avformat_alloc_output_context2()

This avoids having to assign oformat, allows returning the
correct error code and allocates priv_data

Based on patch by: Mika Raento <mika.raento@elisa.fi>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
segment: use mpegts_flags instead of the deprecated resend_headers option

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
segment: fix copying stream metadata

To get mpegts metadata copied when segmenting.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>