Browse code

ogg: Provide an option to offset the serial number

The ogg serial number doubles as codec id and sequence
value for concatenated samples.

Luca Barbato authored on 2015/01/31 01:29:22
Showing 2 changed files
... ...
@@ -504,6 +504,11 @@ is 1 second. A value of 0 will fill all segments, making pages as large as
504 504
 possible. A value of 1 will effectively use 1 packet-per-page in most
505 505
 situations, giving a small seek granularity at the cost of additional container
506 506
 overhead.
507
+@item -serial_offset @var{value}
508
+Serial value from which to set the streams serial number.
509
+Setting it to different and sufficiently large values ensures that the produced
510
+ogg files can be safely chained.
511
+
507 512
 @end table
508 513
 
509 514
 @section segment
... ...
@@ -71,12 +71,15 @@ typedef struct {
71 71
     OGGPageList *page_list;
72 72
     int pref_size; ///< preferred page size (0 => fill all segments)
73 73
     int64_t pref_duration;      ///< preferred page duration (0 => fill all segments)
74
+    int serial_offset;
74 75
 } OGGContext;
75 76
 
76 77
 #define OFFSET(x) offsetof(OGGContext, x)
77 78
 #define PARAM AV_OPT_FLAG_ENCODING_PARAM
78 79
 
79 80
 static const AVOption options[] = {
81
+    { "serial_offset", "serial number offset",
82
+        OFFSET(serial_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, PARAM },
80 83
     { "pagesize", "preferred page size in bytes (deprecated)",
81 84
         OFFSET(pref_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_PAGE_SIZE, PARAM },
82 85
     { "page_duration", "preferred page duration, in microseconds",
... ...
@@ -418,7 +421,7 @@ static int ogg_write_header(AVFormatContext *s)
418 418
 
419 419
     for (i = 0; i < s->nb_streams; i++) {
420 420
         AVStream *st = s->streams[i];
421
-        unsigned serial_num = i;
421
+        unsigned serial_num = i + ogg->serial_offset;
422 422
 
423 423
         if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
424 424
             if (st->codec->codec_id == AV_CODEC_ID_OPUS)