Ticket #2547: 0001-libavformat-segment.c-add-muxrate-option-for-segment.patch

File 0001-libavformat-segment.c-add-muxrate-option-for-segment.patch, 2.9 KB (added by Jason Livingston, 13 years ago)

patch needed to pass muxrate option to stream_segment muxer

  • libavformat/segment.c

    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 {  
    9898    SegmentListEntry *segment_list_entries_end;
    9999
    100100    int is_first_pkt;      ///< tells if it is the first packet in the segment
     101    char *muxrate_str;
    101102} SegmentContext;
    102103
    103104static void print_csv_escaped_str(AVIOContext *ctx, const char *str)
    static int segment_start(AVFormatContext *s, int write_header)  
    172173    SegmentContext *seg = s->priv_data;
    173174    AVFormatContext *oc = seg->avf;
    174175    int err = 0;
     176    AVDictionary *opts = NULL;
    175177
    176178    if (write_header) {
    177179        avformat_free_context(oc);
    static int segment_start(AVFormatContext *s, int write_header)  
    194196        av_opt_set(oc->priv_data, "resend_headers", "1", 0); /* mpegts specific */
    195197
    196198    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)
    198202            return err;
    199203    }
    200204
    static int seg_write_header(AVFormatContext *s)  
    507511    SegmentContext *seg = s->priv_data;
    508512    AVFormatContext *oc = NULL;
    509513    int ret;
     514    AVDictionary *opts = NULL;
    510515
    511516    seg->segment_count = 0;
    512517    if (!seg->write_header_trailer)
    static int seg_write_header(AVFormatContext *s)  
    595600            goto fail;
    596601    }
    597602
    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) {
    599606        avio_close(oc->pb);
    600607        goto fail;
    601608    }
    fail:  
    749756static const AVOption options[] = {
    750757    { "reference_stream",  "set reference stream", OFFSET(reference_stream_specifier), AV_OPT_TYPE_STRING, {.str = "auto"}, CHAR_MIN, CHAR_MAX, E },
    751758    { "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 },
    752760    { "segment_list",      "set the segment list filename",              OFFSET(list),    AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,       E },
    753761
    754762    { "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"},