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

Rodger Combs rodger.combs at gmail.com
Fri Nov 21 04:47:55 CET 2014


> On Nov 20, 2014, at 02:41, Benoit Fouet <benoit.fouet at free.fr> wrote:
> 
> Hi,
> 
> ----- Mail original -----
>> 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 },
>> 
> 
> Default should be 1, in order not to change the current behavior.
> 
> -- 
> Ben
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org <mailto:ffmpeg-devel at ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
Alright, here's a version with that. Also, adjusted to reflect the change properly in the MPD.

From ec2b7e5033acb25bb0310f12ea576a8185f4e396 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

---
 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