4

I am referring a media source api demo given on this link

It is working fine for the given test webm file but when i tried to change the name of the file to a custom webm file the code stopped working.

It is generating following error : Uncaught Error: INVALID_STATE_ERR: DOM Exception 11 at following code : sourceBuffer.append(new Uint8Array(e.target.result));

To check whether the custom webm file is working i have created a test page in which i have defined a video tag having source of that custom webm file. When i ran the code it is working fine.

I am unable to understand the reason for this strange behavior.

Kevin Ennis
  • 14,226
  • 2
  • 43
  • 44
Pankaj Khurana
  • 3,243
  • 10
  • 50
  • 79

2 Answers2

18

The most likely problem is your WebM file has Clusters that don't start with a keyframe.

In Chrome dev-channel builds (ie Chrome 25 or later), you can verify this with the following steps.

  1. Open chrome:media-internals in another tab.
  2. Return to the tab with your test page and reload it.
  3. When the error occurs again, switch back to chrome:media-internals tab and look for the bottom entry under the "Active media players:" header. It should have the same blob: URL that you passed to the video element src attribute.
  4. Click on the blob: URL to expand the player data.
  5. Click on the "Log:" entry to expose the player logging data.
  6. Search for entries that have "MEDIA_SOURCE_ERROR" in the "Event:" column. These entries should provide information about what is wrong with the content passed to the browser.

If you see a message that says something like "Media segment did not begin with keyframe." then it means your file has Clusters that don't start with a keyframe. This is common with content that is generated by FFmpeg. You can fix your file in one of the following ways:

  1. Run the sample_muxer program mentioned in section 2.2.5 of the WebM adaptive streaming guide
  2. Run the mse_webm_remuxer program I wrote as part of my mse-tools project.
Aaron Colwell
  • 286
  • 2
  • 2
  • thanks aaron for replying. i have followed the steps as mentioned by you and found out that the error was same as mentioned by you. – Pankaj Khurana Dec 27 '12 at 07:09
  • Now i am following the step 1 that is run the sample_muxer program. I have visited the link as mentioned by you. I have read the prerequisites in which it is mentioned that FFmpeg, libwebm and webm-tools are required. I have downloaded the windows builds of FFmpeg and added in the environment variable path and checked in the cmd. I have downloaded the libwebm folder but i dont know how to configure it and the third prerequisite webm-tools link there is nothing to download. Please help me to make it working. – Pankaj Khurana Dec 27 '12 at 07:57
  • After analyzing the code i found out that simple_muxer is a application built in cpp. I have installed the Dev-C++ software but when i try to compile the file sound_mixer.cpp i am getting errors – Pankaj Khurana Dec 27 '12 at 12:27
  • The second approach of running the mse_webm_remuxer progran has worked for me. Thanks aaron for your valuable suggestion. – Pankaj Khurana Dec 28 '12 at 19:03
  • 1
    You can prevent FFmpeg from creating clusters without keyframes if you set the cluster size limit high enough; I use "-cluster_size_limit 10M -cluster_time_limit 10K" – Tangent 128 Nov 06 '15 at 21:53
0

UPDATE: no internal error shown in my case (accepted answer suggests to check) but still the same problem

I ran into the same trouble when trying to play recorded .webm file by MediaRecorder API back using Media Source Extensions (MSE). Chrome (51) recordings are malformed, Firefox (46) seems OK.

To get it working you have to fix cues in .webm file:

  1. clone https://github.com/webmproject/libwebm
  2. make sure you have cmake version >= 3.2 (https://askubuntu.com/questions/610291/how-to-install-cmake-3-2-on-ubuntu-14-04)
  3. cmake .
  4. make
  5. ./sample_muxer -i original.webm -o fixed.webm
  6. load fixed.webm into DASH / your own player!

Hope it helped someone. It was quite difficult to google any information without the DASH keyword (i am not using DASH, only the same underlying technology - MSE) :)

Community
  • 1
  • 1
lukyer
  • 7,595
  • 3
  • 37
  • 31
  • I've been wrestling with this for awhile now. Are you aware of a way this can work in chrome? Maybe by fixing the webm in real time? – Tyler Biscoe Jul 31 '17 at 05:24
  • it should work in Chrome. It has been a while i wrote this but it was working in Chrome, Firefox and Opera. – lukyer Jul 31 '17 at 08:27
  • Hey sorry, I meant is there a way to record using the MediaRecorder API that will immediately playable in Chrome. Without the need to remux the video. – Tyler Biscoe Jul 31 '17 at 15:06
  • It was not possible in Chrome 51. Maybe it is working now, i have not tried it. However if you do not need recording, you do not have to use MediaRecorderAPI (for example if you just want to show/stream MediaStream). – lukyer Jul 31 '17 at 15:16