Opened 4 months ago
Last modified 4 months ago
#10770 new defect
avcodec_open2 overwrites flags contrary to what the doc says
Reported by: | Jean-Michaël Celerier | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | unspecified | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
The avcodec_open2 documentation states, about the options parameter:
* @param options A dictionary filled with AVCodecContext and codec-private * options, which are set on top of the options already set in * avctx, can be NULL. On return this object will be filled with * options that were not found in the avctx codec context.
Yet given the following program, the final assert does not pass: AV_CODEC_FLAG_GLOBAL_HEADER gets overwritten in the codec context's flags.
extern "C" { #include <libavcodec/avcodec.h> } #include <cassert> int main() { auto codec = avcodec_find_encoder_by_name("libx264"); auto c = avcodec_alloc_context3(codec); c->width = 1280; c->height = 720; c->time_base = (AVRational){100000, int(100000 * 30)}; c->framerate = AVRational{c->time_base.den, c->time_base.num}; c->gop_size = 0; c->max_b_frames = 0; c->pix_fmt = AV_PIX_FMT_YUV420P; c->strict_std_compliance = FF_COMPLIANCE_NORMAL; c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; AVDictionary* opt{}; av_dict_set(&opt, "flags", "low_delay", 0); avcodec_open2(c, codec, &opt); assert(c->flags & AV_CODEC_FLAG_GLOBAL_HEADER); }
Note:
See TracTickets
for help on using tickets.
I think you'll find that the flag is overwritten by
av_dict_set
. Use the value"+low_delay"
and then check.