New issue
Advanced search Search tips

Issue 892214 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Oct 4
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

MediaRecorder produces bad webm chunks

Reported by antonpri...@gmail.com, Oct 4

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36

Steps to reproduce the problem:
I'm using MediaRecorder API to record the speech on a web page. As an output, I'm getting the media chunks which represent parts of WebM audio.

Here is the code which is recording data:

`navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(function(stream) {
  recorder = new MediaRecorder(stream, { mimeType: 'audio/webm; codecs="opus"' })
  recorder.ondataavailable = function(e) {
    // Read blob from `e.data`, and send to sever;
  }
  recorder.start(1000)
})`

Those chunks cannot be played "as is", because they do not contain file headers. An only first chunk contains those headers, so if I want to play some part of the audio without combining the whole track, I'm concatenating the first chunk with the chunks I need to play and cut the audio with FFmpeg after. Like this:

`cat chunk_000.bin chunk_030.bin chunk_031.bin chunk_032.bin chunk_033.bin | ffmpeg -y -i - out.wav`

What is the expected behavior?
The expected behavior is that it does not matter which chunks we start with if the first chunk is attached

What went wrong?
But sometimes the data in those chunks is not playing after such concatenation (in the attached example it happens to chunk_059.bin file):

`cat chunk_000.bin chunk_059.bin | ffmpeg -y -i - out.wav`
This command gives an error:
[matroska,webm @ 0x2131100] Invalid track number 13569
[matroska,webm @ 0x2131100] Invalid stream 13569 or size 948

Though, if the problematic chunk appears in the middle of sequence - it works well:
`cat chunk_000.bin chunk_058.bin chunk_059.bin chunk_060.bin | ffmpeg -y -i - out.wav`

Did this work before? N/A 

Chrome version: 69.0.3497.100  Channel: stable
OS Version: OS X 10.13.6
Flash Version: 

Am I using this correctly? The "broken" chunks appear ~ once per 400 chunks?
 
webm_parts.tar.gz
610 KB Download
Labels: Needs-Triage-M69
Components: -Blink Blink>MediaRecording
Status: Untriaged (was: Unconfirmed)
Status: WontFix (was: Untriaged)
antonpriadko@ the idea that individual Blobs would be playable was never
part of the specification [1]:

"When multiple Blobs are returned (because of timeslice or requestData()), 
the individual Blobs need not be playable, but the combination of all the 
Blobs from a completed recording MUST be playable."

You are assuming that the first blob is the header and then any subsequent
one is going to fall on an integer multiple of a muxed audio/video frame,
but webm/matroska doesn't guarantee that and as a matter of fact it tends
to e.g. produce the header in multiple small blobs (and not in one).

For your purpose (IIUC), you'll have to use a library like e.g. ts-ebml [2]
to disassemble the webm stream to retrieve the individual encoded video
frames or audio chunks.

[1] https://www.w3.org/TR/mediastream-recording/#dom-mediarecorder-start
[2] https://github.com/legokichi/ts-ebml

Sign in to add a comment