| 1 | diff --git a/libavformat/segment.c b/libavformat/segment.c |
|---|
| 2 | index 13d8c43..7f5b947 100644 |
|---|
| 3 | --- a/libavformat/segment.c |
|---|
| 4 | +++ b/libavformat/segment.c |
|---|
| 5 | @@ -174,11 +174,24 @@ static int segment_start(AVFormatContext *s, int write_header) |
|---|
| 6 | int err = 0; |
|---|
| 7 | |
|---|
| 8 | if (write_header) { |
|---|
| 9 | + |
|---|
| 10 | + AVDictionary *tmp = NULL; |
|---|
| 11 | + |
|---|
| 12 | + if (av_dict_count(s->metadata) != 0) |
|---|
| 13 | + { |
|---|
| 14 | + av_dict_copy(&tmp, s->metadata, 0); |
|---|
| 15 | + } |
|---|
| 16 | + else if (av_dict_count(oc->metadata) != 0) |
|---|
| 17 | + { |
|---|
| 18 | + av_dict_copy(&tmp, oc->metadata, 0); |
|---|
| 19 | + } |
|---|
| 20 | + |
|---|
| 21 | avformat_free_context(oc); |
|---|
| 22 | seg->avf = NULL; |
|---|
| 23 | if ((err = segment_mux_init(s)) < 0) |
|---|
| 24 | return err; |
|---|
| 25 | oc = seg->avf; |
|---|
| 26 | + av_dict_copy(&oc->metadata, tmp, 0); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | seg->segment_idx++; |
|---|