ffmpeg_opt: Use av_guess_codec() instead of AVOutputFormat->*codec

Fixes part of ticket2236

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avformat/format: use av_match_name() in av_guess_codec()

Fixes part of Ticket2236

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avformat/format: Check for av_guess_format() failure

Fixes null pointer dereference
Fixes Ticket3812

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