avconv: try to match codecs by codec descriptor name as a last resort.

This allows e.g. -c:v h264 to select the libx264 encoder.
This commit is contained in:
Anton Khirnov 2012-08-11 15:40:12 +02:00
parent f617135bc9
commit db4766ad1b
1 changed files with 10 additions and 0 deletions

View File

@ -381,12 +381,22 @@ static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFor
static AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder)
{
const AVCodecDescriptor *desc;
const char *codec_string = encoder ? "encoder" : "decoder";
AVCodec *codec;
codec = encoder ?
avcodec_find_encoder_by_name(name) :
avcodec_find_decoder_by_name(name);
if (!codec && (desc = avcodec_descriptor_get_by_name(name))) {
codec = encoder ? avcodec_find_encoder(desc->id) :
avcodec_find_decoder(desc->id);
if (codec)
av_log(NULL, AV_LOG_VERBOSE, "Matched %s '%s' for codec '%s'.\n",
codec_string, codec->name, desc->name);
}
if (!codec) {
av_log(NULL, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
exit_program(1);