- if (avctx->oformat->flags & AVFMT_GLOBALHEADER) {
- avstream_video->codec->flags = AV_CODEC_FLAG_GLOBAL_HEADER;
+
+ if (!video_extradata.empty()) {
+ avstream_video->codec->extradata = (uint8_t *)av_malloc(video_extradata.size());
+ avstream_video->codec->extradata_size = video_extradata.size();
+ memcpy(avstream_video->codec->extradata, video_extradata.data(), video_extradata.size());