[PATCH] lavf/matroska: Adding the new SeekPreRoll element
In order to encapsuate Opus in Matroska, there is a new element that has been added to the Matroska Spec, SeekPreRoll. It has the duration in nanoseconds that has to be decoded before every seek. Spec: http://matroska.org/technical/specs/index.html#SeekPreRoll Proposal for encapsulateing Opus in Matroska: http://wiki.xiph.org/MatroskaOpus Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 2eb2fe6..9c8071a 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -91,6 +91,7 @@ #define MATROSKA_ID_CODECINFOURL 0x3B4040 #define MATROSKA_ID_CODECDOWNLOADURL 0x26B240 #define MATROSKA_ID_CODECDECODEALL 0xAA +#define MATROSKA_ID_SEEKPREROLL 0x56BB #define MATROSKA_ID_TRACKNAME 0x536E #define MATROSKA_ID_TRACKLANGUAGE 0x22B59C #define MATROSKA_ID_TRACKFLAGENABLED 0xB9 diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c201d5e..56109f9 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -121,6 +121,9 @@ typedef struct MatroskaMuxContext { /** per-cuepoint - 2 1-byte EBML IDs, 2 1-byte EBML sizes, 8-byte uint max */ #define MAX_CUEPOINT_SIZE(num_tracks) 12 + MAX_CUETRACKPOS_SIZE*num_tracks +/** Seek preroll value for opus */ +#define OPUS_SEEK_PREROLL 80000000 + static int ebml_id_size(unsigned int id) { @@ -642,6 +645,10 @@ static int mkv_write_tracks(AVFormatContext *s) } } + if (codec->codec_id == AV_CODEC_ID_OPUS) { + put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL); + } + if (mkv->mode == MODE_WEBM && !(codec->codec_id == AV_CODEC_ID_VP8 || codec->codec_id == AV_CODEC_ID_VP9 || ((codec->codec_id == AV_CODEC_ID_OPUS)&&(codec->strict_std_compliance <= FF_COMPLIANCE_EXPERIMENTAL)) || @@ -1721,6 +1728,7 @@ AVOutputFormat ff_matroska_audio_muxer = { .priv_data_size = sizeof(MatroskaMuxContext), .audio_codec = CONFIG_LIBVORBIS_ENCODER ? AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3, + AV_CODEC_ID_OPUS, .video_codec = AV_CODEC_ID_NONE, .write_header = mkv_write_header, .write_packet = mkv_write_packet, -- 1.8.3
Le nonidi 29 thermidor, an CCXXI, Vignesh Venkatasubramanian a écrit :
.audio_codec = CONFIG_LIBVORBIS_ENCODER ? AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3, + AV_CODEC_ID_OPUS, .video_codec = AV_CODEC_ID_NONE,
This hunk looks strange: it seems to be adding AV_CODEC_ID_OPUS as an initializer with no designation, in the random middle of the struct. Can you explain? Regards, -- Nicolas George
On 8/16/13, Vignesh Venkatasubramanian <vigneshv@google.com> wrote:
In order to encapsuate Opus in Matroska, there is a new element that has been added to the Matroska Spec, SeekPreRoll. It has the duration in nanoseconds that has to be decoded before every seek. Spec: http://matroska.org/technical/specs/index.html#SeekPreRoll Proposal for encapsulateing Opus in Matroska: http://wiki.xiph.org/MatroskaOpus
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 8 ++++++++ 2 files changed, 9 insertions(+)
diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 2eb2fe6..9c8071a 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -91,6 +91,7 @@ #define MATROSKA_ID_CODECINFOURL 0x3B4040 #define MATROSKA_ID_CODECDOWNLOADURL 0x26B240 #define MATROSKA_ID_CODECDECODEALL 0xAA +#define MATROSKA_ID_SEEKPREROLL 0x56BB #define MATROSKA_ID_TRACKNAME 0x536E #define MATROSKA_ID_TRACKLANGUAGE 0x22B59C #define MATROSKA_ID_TRACKFLAGENABLED 0xB9
Keep alphabetical order.
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c201d5e..56109f9 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -121,6 +121,9 @@ typedef struct MatroskaMuxContext { /** per-cuepoint - 2 1-byte EBML IDs, 2 1-byte EBML sizes, 8-byte uint max */ #define MAX_CUEPOINT_SIZE(num_tracks) 12 + MAX_CUETRACKPOS_SIZE*num_tracks
+/** Seek preroll value for opus */ +#define OPUS_SEEK_PREROLL 80000000 +
static int ebml_id_size(unsigned int id) { @@ -642,6 +645,10 @@ static int mkv_write_tracks(AVFormatContext *s) } }
+ if (codec->codec_id == AV_CODEC_ID_OPUS) { + put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL); + } + if (mkv->mode == MODE_WEBM && !(codec->codec_id == AV_CODEC_ID_VP8 || codec->codec_id == AV_CODEC_ID_VP9 || ((codec->codec_id == AV_CODEC_ID_OPUS)&&(codec->strict_std_compliance <= FF_COMPLIANCE_EXPERIMENTAL)) || @@ -1721,6 +1728,7 @@ AVOutputFormat ff_matroska_audio_muxer = { .priv_data_size = sizeof(MatroskaMuxContext), .audio_codec = CONFIG_LIBVORBIS_ENCODER ? AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3, + AV_CODEC_ID_OPUS,
Unrelated and wrong.
.video_codec = AV_CODEC_ID_NONE, .write_header = mkv_write_header, .write_packet = mkv_write_packet, -- 1.8.3
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
On Fri, Aug 16, 2013 at 10:36 AM, Paul B Mahol <onemda@gmail.com> wrote:
On 8/16/13, Vignesh Venkatasubramanian <vigneshv@google.com> wrote:
In order to encapsuate Opus in Matroska, there is a new element that has been added to the Matroska Spec, SeekPreRoll. It has the duration in nanoseconds that has to be decoded before every seek. Spec: http://matroska.org/technical/specs/index.html#SeekPreRoll Proposal for encapsulateing Opus in Matroska: http://wiki.xiph.org/MatroskaOpus
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 8 ++++++++ 2 files changed, 9 insertions(+)
diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 2eb2fe6..9c8071a 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -91,6 +91,7 @@ #define MATROSKA_ID_CODECINFOURL 0x3B4040 #define MATROSKA_ID_CODECDOWNLOADURL 0x26B240 #define MATROSKA_ID_CODECDECODEALL 0xAA +#define MATROSKA_ID_SEEKPREROLL 0x56BB #define MATROSKA_ID_TRACKNAME 0x536E #define MATROSKA_ID_TRACKLANGUAGE 0x22B59C #define MATROSKA_ID_TRACKFLAGENABLED 0xB9
Keep alphabetical order.
Not sure what you mean. S comes in between C and T. Could you please explain?
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c201d5e..56109f9 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -121,6 +121,9 @@ typedef struct MatroskaMuxContext { /** per-cuepoint - 2 1-byte EBML IDs, 2 1-byte EBML sizes, 8-byte uint max */ #define MAX_CUEPOINT_SIZE(num_tracks) 12 + MAX_CUETRACKPOS_SIZE*num_tracks
+/** Seek preroll value for opus */ +#define OPUS_SEEK_PREROLL 80000000 +
static int ebml_id_size(unsigned int id) { @@ -642,6 +645,10 @@ static int mkv_write_tracks(AVFormatContext *s) } }
+ if (codec->codec_id == AV_CODEC_ID_OPUS) { + put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL); + } + if (mkv->mode == MODE_WEBM && !(codec->codec_id == AV_CODEC_ID_VP8 || codec->codec_id == AV_CODEC_ID_VP9 || ((codec->codec_id == AV_CODEC_ID_OPUS)&&(codec->strict_std_compliance <= FF_COMPLIANCE_EXPERIMENTAL)) || @@ -1721,6 +1728,7 @@ AVOutputFormat ff_matroska_audio_muxer = { .priv_data_size = sizeof(MatroskaMuxContext), .audio_codec = CONFIG_LIBVORBIS_ENCODER ? AV_CODEC_ID_VORBIS : AV_CODEC_ID_AC3, + AV_CODEC_ID_OPUS,
Unrelated and wrong.
Sorry, some debug play around that snuck in by mistake. Will fix.
.video_codec = AV_CODEC_ID_NONE, .write_header = mkv_write_header, .write_packet = mkv_write_packet, -- 1.8.3
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
In order to encapsuate Opus in Matroska, there is a new element that has been added to the Matroska Spec, SeekPreRoll. It has the duration in nanoseconds that has to be decoded before every seek. Spec: http://matroska.org/technical/specs/index.html#SeekPreRoll Proposal for encapsulateing Opus in Matroska: http://wiki.xiph.org/MatroskaOpus Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 2eb2fe6..9c8071a 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -91,6 +91,7 @@ #define MATROSKA_ID_CODECINFOURL 0x3B4040 #define MATROSKA_ID_CODECDOWNLOADURL 0x26B240 #define MATROSKA_ID_CODECDECODEALL 0xAA +#define MATROSKA_ID_SEEKPREROLL 0x56BB #define MATROSKA_ID_TRACKNAME 0x536E #define MATROSKA_ID_TRACKLANGUAGE 0x22B59C #define MATROSKA_ID_TRACKFLAGENABLED 0xB9 diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c201d5e..18e96c3 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -121,6 +121,9 @@ typedef struct MatroskaMuxContext { /** per-cuepoint - 2 1-byte EBML IDs, 2 1-byte EBML sizes, 8-byte uint max */ #define MAX_CUEPOINT_SIZE(num_tracks) 12 + MAX_CUETRACKPOS_SIZE*num_tracks +/** Seek preroll value for opus */ +#define OPUS_SEEK_PREROLL 80000000 + static int ebml_id_size(unsigned int id) { @@ -642,6 +645,10 @@ static int mkv_write_tracks(AVFormatContext *s) } } + if (codec->codec_id == AV_CODEC_ID_OPUS) { + put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL); + } + if (mkv->mode == MODE_WEBM && !(codec->codec_id == AV_CODEC_ID_VP8 || codec->codec_id == AV_CODEC_ID_VP9 || ((codec->codec_id == AV_CODEC_ID_OPUS)&&(codec->strict_std_compliance <= FF_COMPLIANCE_EXPERIMENTAL)) || -- 1.8.3
On 8/16/13, Vignesh Venkatasubramanian <vigneshv@google.com> wrote:
In order to encapsuate Opus in Matroska, there is a new element that has been added to the Matroska Spec, SeekPreRoll. It has the duration in nanoseconds that has to be decoded before every seek. Spec: http://matroska.org/technical/specs/index.html#SeekPreRoll Proposal for encapsulateing Opus in Matroska: http://wiki.xiph.org/MatroskaOpus
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 7 +++++++ 2 files changed, 8 insertions(+)
I have no more comments, Michael?
On Sat, Aug 17, 2013 at 09:31:04AM +0000, Paul B Mahol wrote:
On 8/16/13, Vignesh Venkatasubramanian <vigneshv@google.com> wrote:
In order to encapsuate Opus in Matroska, there is a new element that has been added to the Matroska Spec, SeekPreRoll. It has the duration in nanoseconds that has to be decoded before every seek. Spec: http://matroska.org/technical/specs/index.html#SeekPreRoll Proposal for encapsulateing Opus in Matroska: http://wiki.xiph.org/MatroskaOpus
Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> --- libavformat/matroska.h | 1 + libavformat/matroskaenc.c | 7 +++++++ 2 files changed, 8 insertions(+)
I have no more comments, Michael?
applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No great genius has ever existed without some touch of madness. -- Aristotle
participants (4)
-
Michael Niedermayer -
Nicolas George -
Paul B Mahol -
Vignesh Venkatasubramanian