[FFmpeg-cvslog] ogg: Provide an option to offset the serial number

Luca Barbato git at videolan.org
Sun Feb 1 13:33:58 CET 2015


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Fri Jan 30 17:29:22 2015 +0100| [f726fc21ef76a8ba3445448066f7b2a687fbca16] | committer: Luca Barbato

ogg: Provide an option to offset the serial number

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

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f726fc21ef76a8ba3445448066f7b2a687fbca16
---

 doc/muxers.texi      |    5 +++++
 libavformat/oggenc.c |    5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index d71eb09..bcfdb49 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -504,6 +504,11 @@ is 1 second. A value of 0 will fill all segments, making pages as large as
 possible. A value of 1 will effectively use 1 packet-per-page in most
 situations, giving a small seek granularity at the cost of additional container
 overhead.
+ at item -serial_offset @var{value}
+Serial value from which to set the streams serial number.
+Setting it to different and sufficiently large values ensures that the produced
+ogg files can be safely chained.
+
 @end table
 
 @section segment
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index c7d6491..1b2644d 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -71,12 +71,15 @@ typedef struct {
     OGGPageList *page_list;
     int pref_size; ///< preferred page size (0 => fill all segments)
     int64_t pref_duration;      ///< preferred page duration (0 => fill all segments)
+    int serial_offset;
 } OGGContext;
 
 #define OFFSET(x) offsetof(OGGContext, x)
 #define PARAM AV_OPT_FLAG_ENCODING_PARAM
 
 static const AVOption options[] = {
+    { "serial_offset", "serial number offset",
+        OFFSET(serial_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, PARAM },
     { "pagesize", "preferred page size in bytes (deprecated)",
         OFFSET(pref_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_PAGE_SIZE, PARAM },
     { "page_duration", "preferred page duration, in microseconds",
@@ -418,7 +421,7 @@ static int ogg_write_header(AVFormatContext *s)
 
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
-        unsigned serial_num = i;
+        unsigned serial_num = i + ogg->serial_offset;
 
         if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
             if (st->codec->codec_id == AV_CODEC_ID_OPUS)



More information about the ffmpeg-cvslog mailing list