The out codecontext are determined before the encoder is openend and only once.
Second we now try to determine the best fitting sample_fmt and channel_layout for the encoder. Based on was is has available.

Tested with encoder MPEG2, AAC and Vorbis.

Signed-off-by: Michel Verbraak <info@1st-setup.nl>