X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fsegment.c;h=6e37707f9f07ba878fa4db2a9cf9ade7137d2724;hb=79aa91d562a53187d0b381da7203110f16cc1bb6;hp=e2ac2c3a7f3d8c55f2da992cdb73494f9054fbf7;hpb=fda424b300c1a0b991296aa585691609d01196bd;p=ffmpeg diff --git a/libavformat/segment.c b/libavformat/segment.c index e2ac2c3a7f3..6e37707f9f0 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -72,7 +72,7 @@ typedef struct SegmentContext { int segment_idx_wrap; ///< number after which the index wraps int segment_idx_wrap_nb; ///< number of time the index has wraped int segment_count; ///< number of segment files already written - AVOutputFormat *oformat; + ff_const59 AVOutputFormat *oformat; AVFormatContext *avf; char *format; ///< format to use for output segment files char *format_options_str; ///< format options to use for output segment files @@ -859,6 +859,20 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) if (!seg->avf || !seg->avf->pb) return AVERROR(EINVAL); + if (!st->codecpar->extradata_size) { + int pkt_extradata_size = 0; + uint8_t *pkt_extradata = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &pkt_extradata_size); + if (pkt_extradata && pkt_extradata_size > 0) { + ret = ff_alloc_extradata(st->codecpar, pkt_extradata_size); + if (ret < 0) { + av_log(s, AV_LOG_WARNING, "Unable to add extradata to stream. Output segments may be invalid.\n"); + goto calc_times; + } + memcpy(st->codecpar->extradata, pkt_extradata, pkt_extradata_size); + st->codecpar->extradata_size = pkt_extradata_size; + } + } + calc_times: if (seg->times) { end_pts = seg->segment_count < seg->nb_times ?