From 0f4d22beb9ad5eaa0fce4070681616611b756ba5 Mon Sep 17 00:00:00 2001
From: Jason Livingston <jason@cpcweb.com>
Date: Wed, 8 May 2013 23:14:28 -0400
Subject: [PATCH] libavformat/segment.c: add muxrate option for segment format
---
libavformat/segment.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 13d8c43..89d8cce 100644
|
a
|
b
|
typedef struct {
|
| 98 | 98 | SegmentListEntry *segment_list_entries_end; |
| 99 | 99 | |
| 100 | 100 | int is_first_pkt; ///< tells if it is the first packet in the segment |
| | 101 | char *muxrate_str; |
| 101 | 102 | } SegmentContext; |
| 102 | 103 | |
| 103 | 104 | static void print_csv_escaped_str(AVIOContext *ctx, const char *str) |
| … |
… |
static int segment_start(AVFormatContext *s, int write_header)
|
| 172 | 173 | SegmentContext *seg = s->priv_data; |
| 173 | 174 | AVFormatContext *oc = seg->avf; |
| 174 | 175 | int err = 0; |
| | 176 | AVDictionary *opts = NULL; |
| 175 | 177 | |
| 176 | 178 | if (write_header) { |
| 177 | 179 | avformat_free_context(oc); |
| … |
… |
static int segment_start(AVFormatContext *s, int write_header)
|
| 194 | 196 | av_opt_set(oc->priv_data, "resend_headers", "1", 0); /* mpegts specific */ |
| 195 | 197 | |
| 196 | 198 | if (write_header) { |
| 197 | | if ((err = avformat_write_header(oc, NULL)) < 0) |
| | 199 | if (seg->muxrate_str) |
| | 200 | av_dict_set(&opts, "muxrate", seg->muxrate_str, 0); |
| | 201 | if ((err = avformat_write_header(oc, &opts)) < 0) |
| 198 | 202 | return err; |
| 199 | 203 | } |
| 200 | 204 | |
| … |
… |
static int seg_write_header(AVFormatContext *s)
|
| 507 | 511 | SegmentContext *seg = s->priv_data; |
| 508 | 512 | AVFormatContext *oc = NULL; |
| 509 | 513 | int ret; |
| | 514 | AVDictionary *opts = NULL; |
| 510 | 515 | |
| 511 | 516 | seg->segment_count = 0; |
| 512 | 517 | if (!seg->write_header_trailer) |
| … |
… |
static int seg_write_header(AVFormatContext *s)
|
| 595 | 600 | goto fail; |
| 596 | 601 | } |
| 597 | 602 | |
| 598 | | if ((ret = avformat_write_header(oc, NULL)) < 0) { |
| | 603 | if (seg->muxrate_str) |
| | 604 | av_dict_set(&opts, "muxrate", seg->muxrate_str, 0); |
| | 605 | if ((ret = avformat_write_header(oc, &opts)) < 0) { |
| 599 | 606 | avio_close(oc->pb); |
| 600 | 607 | goto fail; |
| 601 | 608 | } |
| … |
… |
fail:
|
| 749 | 756 | static const AVOption options[] = { |
| 750 | 757 | { "reference_stream", "set reference stream", OFFSET(reference_stream_specifier), AV_OPT_TYPE_STRING, {.str = "auto"}, CHAR_MIN, CHAR_MAX, E }, |
| 751 | 758 | { "segment_format", "set container format used for the segments", OFFSET(format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E }, |
| | 759 | { "segment_format_muxrate", "set muxrate for container format", OFFSET(muxrate_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E }, |
| 752 | 760 | { "segment_list", "set the segment list filename", OFFSET(list), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E }, |
| 753 | 761 | |
| 754 | 762 | { "segment_list_flags","set flags affecting segment list generation", OFFSET(list_flags), AV_OPT_TYPE_FLAGS, {.i64 = SEGMENT_LIST_FLAG_CACHE }, 0, UINT_MAX, E, "list_flags"}, |