Autodetect output format