muxing vp8+opus

362 views
Skip to first unread message

bryand...@gmail.com

unread,
May 14, 2014, 3:25:44 PM5/14/14
to webm-d...@webmproject.org
I have a WebRTC MCU and I want to write WEBM files containing VP8+Opus.

I'm using the latest muxer source from https://chromium.googlesource.com/webm/libwebm

Is my use case currently supported by the muxer library?

In one file webm file that I found that does play in Chrome, the DocTypeVersion is 4, while libwebm always writes an EbmlHeader containing a DoctypeVersion of 2.  What is the correct DocTypeVersion to use?

It would be great if the container docs could be updated with information on opus and related changes.


Thanks

Ralph Giles

unread,
May 14, 2014, 5:57:16 PM5/14/14
to webm-d...@webmproject.org
On 2014-05-14 12:25 PM, bryand...@gmail.com wrote:

> I have a WebRTC MCU and I want to write WEBM files containing VP8+Opus.

Hooray, and implementor! :)

> Is my use case currently supported by the muxer library?

From a quick look there's basic support for Opus. There's a
kOpusCodecId, and support for writing the CodecDelay and SeekPreRoll
elements, but you have to generate the Opus CodecPrivate yourself.

> In one file webm file that I found that does play in Chrome, the
> DocTypeVersion is 4, while libwebm always writes an EbmlHeader
> containing a DoctypeVersion of 2. What is the correct DocTypeVersion to
> use?

There's been some dicussion of using DoctypeVersion 4 for VP9 and/or
Opus in webm to distinguish it from VP8/Vorbis webm. Particularly for
the IE plugin, which rejects such files more cleanly than if they just
contain an unrecognized codec.

As I read the spec, DocReadTypeVersion should be 4 for Opus files. Opus
tracks should use the CodecDelay and SeekPreRoll elements. The matroska
spec says they're defined for "Matroska version 4" and "WebM". The WebM
spec says "DocReadTypeVersion SHOULD follow the Matroska specification."
So writing 2 unconditionally is a bug in libwebm.

> It would be great if the container docs could be updated with
> information on opus and related changes.

I agree! There's a rought design document at
https://wiki.xiph.org/MatroskaOpus. You can help by providing
implementation feedback, updating the wiki page, etc.

-r

Soumit Mukherjee

unread,
May 15, 2014, 2:51:00 AM5/15/14
to webm-d...@webmproject.org
You can use this library  for your purpose , I am able to make webm files with vp8 and opus

In mkvmuxer.cpp  just check if you have the following definition 

const char Tracks::kOpusCodecId[] = "A_OPUS";

if not add the line then

uint64 Segment::AddAudioTrack(int32 sample_rate,
                              int32 channels,
                              int32 number) {
  AudioTrack* const track = new (std::nothrow) AudioTrack(&seed_);  // NOLINT
  if (!track)


  track->set_type(Tracks::kAudio);
  track->set_codec_id(Tracks::kOpusCodecId);
  track->set_sample_rate(sample_rate);
  track->set_channels(channels);

It works I am able to write it successfully only issue  is other than my own webmreader (also based on this same library can read it. 
Chrome or firefox does not play the file. In VLC I can see only video but no audio may be the DocTypeVersion issue. 


Regards,
Soumit








--
You received this message because you are subscribed to the Google Groups "WebM Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webm-discuss...@webmproject.org.
To post to this group, send email to webm-d...@webmproject.org.
Visit this group at http://groups.google.com/a/webmproject.org/group/webm-discuss/.
For more options, visit https://groups.google.com/a/webmproject.org/d/optout.



--
Regards,
Soumit
असतो मा सद् गमय:  (From illusion lead me to the Truth);
तमसो मा ज्योितर्गमय (From darkness lead me to Light);
मृत्योर्मामृतं गमय (From death lead me to Immortality)".

bryand...@gmail.com

unread,
May 15, 2014, 3:28:00 PM5/15/14
to webm-d...@webmproject.org
I have produced WebM/Opus files that will play in both Firefox and Chrome.  I spent a while trying to determine why my files, which played fine in AVPlay, would not play in Chrome and Firefox.   It is related to CodecDelay and PreSkip

Chrome will not play an Opus WebM file that has a zero, or absent, CodecDelay.   AVPlay 9.13-6 and Firefox both can play such files.

Firefox will play a file with a zero codec delay, but will not play if the pre-skip in the OpusHead does not match the codec delay.  Beware: The CodecDelay is in nanoseconds, while the PreSkip is in number of samples at 48 kHz.  

PreSkip of 48 (0x30) == 1ms == 1,000,000 ns CodecDelay

I use a DocTypeVersion of 4, and a DocTypeReadVersion of 2 since this combination allows AVPlay to render the files.  It complains about the "unknown" parameters of CodecDelay and SeekPreRoll, but otherwise has no problem.  AVPlay 9.13-6 will not attempt to play files with a DocTypeReadVersion of 4.

libwebm does not even output CodecDelay if the value is set to zero, but given Chrome's limitation, this does not matter for now.

For anyone else struggling with this, you can dump the attached *good* file with mkvinfo


foo.webm
Reply all
Reply to author
Forward
0 new messages