[FFmpeg-devel] [PATCH] dashenc: Add a segment_start_number option

Rodger Combs rodger.combs at gmail.com
Thu Nov 20 08:53:57 CET 2014


From b38a1396e2335e2d0ef2619b5a3890f91c31c8a8 Mon Sep 17 00:00:00 2001
From: Rodger Combs <rodger.combs at gmail.com>
Date: Thu, 20 Nov 2014 01:47:05 -0600
Subject: [PATCH] dashenc: Add a segment_start_number option

This defaults to 0 instead of 1 for consistency with the segment encoder
---
 libavformat/dashenc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index dac217e..5958270 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -80,6 +80,7 @@ typedef struct DASHContext {
     int total_duration;
     char availability_start_time[100];
     char dirname[1024];
+    int segment_start_number;
 } DASHContext;
 
 static int dash_write(void *opaque, uint8_t *buf, int buf_size)
@@ -182,7 +183,7 @@ static void dash_free(AVFormatContext *s)
 
 static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext *c)
 {
-    int i, start_index = 0, start_number = 1;
+    int i, start_index = 0, start_number = c->segment_start_number;
     if (c->window_size) {
         start_index  = FFMAX(os->nb_segments   - c->window_size, 0);
         start_number = FFMAX(os->segment_index - c->window_size, 1);
@@ -512,7 +513,7 @@ static int dash_write_header(AVFormatContext *s)
 
         set_codec_str(s, os->ctx->streams[0]->codec, os->codec_str, sizeof(os->codec_str));
         os->first_dts = AV_NOPTS_VALUE;
-        os->segment_index = 1;
+        os->segment_index = c->segment_start_number;
     }
 
     if (!c->has_video && c->min_seg_duration <= 0) {
@@ -754,6 +755,7 @@ static const AVOption options[] = {
     { "use_template", "Use SegmentTemplate instead of SegmentList", OFFSET(use_template), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, E },
     { "use_timeline", "Use SegmentTimeline in SegmentTemplate", OFFSET(use_timeline), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, E },
     { "single_file", "Store all segments in one file, accessed using byte ranges", OFFSET(single_file), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, E },
+    { "segment_start_number", "first segment number to write", OFFSET(segment_start_number), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, E },
     { NULL },
 };
 
-- 
1.9.1



More information about the ffmpeg-devel mailing list