[FFmpeg-trac] #4706(documentation:open): av_guess_codec ignores short_name, filename, and mime_type
FFmpeg
trac at avcodec.org
Thu Jul 9 11:13:39 CEST 2015
#4706: av_guess_codec ignores short_name, filename, and mime_type
-------------------------------------+-------------------------------------
Reporter: andrewrk | Owner:
Type: defect | Status: open
Priority: minor | Component:
Version: git-master | documentation
Keywords: | Resolution:
Blocking: | Blocked By:
Analyzed by developer: 0 | Reproduced by developer: 0
-------------------------------------+-------------------------------------
Comment (by andrewrk):
> My original interpretation of this ticket was that you argued that the
short_name
> parameter of av_guess_codec() should have precedence over the fmt
parameter. Was I
> correct?
No. The title of the ticket is correct as well as my clarified code
example.
I do not think the short_name of the codec should change what *format* is
used, but I do think the short_name of the codec should change what
*codec* is used.
> Why are you calling av_guess_codec() if you know exactly what codec you
want to use?
The ingredients for choosing a format and codec are:
* format: format short name, filename hint, codec mime type
* codec: the format, codec short name, filename hint, codec mime type
So it seems that the API user should be able to call av_guess_format,
supply the format choosing ingredients, get a format. Then call
av_guess_codec, supply the codec choosing ingredients, get a codec.
But it is not this way. Here's how my code looks currently:
{{{
e->oformat = av_guess_format(encoder->format_short_name,
encoder->filename, encoder->mime_type);
if (!e->oformat) {
groove_encoder_detach(encoder);
av_log(NULL, AV_LOG_ERROR, "unable to determine format\n");
return -1;
}
// av_guess_codec ignores mime_type, filename, and codec_short_name.
see
// https://trac.ffmpeg.org/ticket/4706
// because of this we do a workaround to return the correct codec
based on
// the codec_short_name.
AVCodec *codec = NULL;
if (encoder->codec_short_name) {
codec = avcodec_find_encoder_by_name(encoder->codec_short_name);
if (!codec) {
const AVCodecDescriptor *desc =
avcodec_descriptor_get_by_name(encoder->codec_short_name);
if (desc) {
codec = avcodec_find_encoder(desc->id);
}
}
}
if (!codec) {
enum AVCodecID codec_id = av_guess_codec(e->oformat,
encoder->codec_short_name, encoder->filename,
encoder->mime_type,
AVMEDIA_TYPE_AUDIO);
codec = avcodec_find_encoder(codec_id);
if (!codec) {
groove_encoder_detach(encoder);
av_log(NULL, AV_LOG_ERROR, "unable to find encoder\n");
return -1;
}
}
e->codec = codec;
av_log(NULL, AV_LOG_INFO, "encoder: using codec: %s\n",
codec->long_name);
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/4706#comment:4>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list