1

I have a Video in webm format (like video.webm the duration is 60 seconds)
I want to get specified segment of video (i.e split video) with http header range (Range: 100-200).
In an other word :
I want to get a section of video (e.g. from second 4 to 12) but i don't want to use any converter like ffmpeg. i want to send http request to server & get specified range of webm file.

Can i use this method (http range header)?

Thanks

M2sh
  • 741
  • 1
  • 11
  • 23

1 Answers1

4

Since the source is non-live it should have a Cues block. I think one way to do it is to fetch the start of the file to get to the MetaSeek information which will point you to the Cues box.

Parsing the Cues will give the CueTime, CueTrack, CueClusterPosition, CueBlockNumber etc. You can use the information to find the clusters that you need.

Take a look at the file with mkvinfo in verbose level 3 to see how it's organized (mkvinfo -v -v -v input.webm).

Example output:

+ Cues at 3441
| + Cue point at 3447
|  + Cue time: 0.000s at 3449
|  + Cue track positions at 3452
|   + Cue track: 1 at 3454
|   + Cue cluster position: 3911 at 3457
| + Cue point at 3461
|  + Cue time: 0.600s at 3463
|  + Cue track positions at 3467
|   + Cue track: 1 at 3469
|   + Cue cluster position: 3911 at 3472
|   + Cue block number: 42 at 3476
| + Cue point at 3480
|  + Cue time: 3.520s at 3482
|  + Cue track positions at 3486
|   + Cue track: 1 at 3488
|   + Cue cluster position: 3911 at 3491
|   + Cue block number: 241 at 3495

You can also find the Matroska specifications here. WebM is a subset, see the specs here.

Update: I found an example on how to use HTTP Range request to download a cluster here. It uses the Media Source Extension Tools to dump the WebM info in JSON.

aergistal
  • 29,947
  • 5
  • 70
  • 92
  • Thanks for your answer. so now i should recognizing the Cues & other parameter? – M2sh Sep 02 '15 at 09:09
  • 1
    @M2sh See the updated answer, I found you an example with `HTTP Range` and an easier way to parse the file. – aergistal Sep 02 '15 at 09:17
  • Hi, i would like to ask you if you have managed how to compose SourceBuffer from chunks out of order? If composing chunk by chunk everything works fine on properly formatted webm file. However if i want to load chunks in parallel i only get errors like `DOMException: Failed to execute 'appendBuffer' on 'SourceBuffer': The HTMLMediaElement.error attribute is not null.` . Thank you. – lukyer Jun 13 '16 at 13:12
  • 1
    @lukyer, try register the event [SourceBuffer.buffered](https://developer.mozilla.org/en-US/docs/Web/API/SourceBuffer/buffered) – BartMao Jun 17 '16 at 03:09
  • @BartMao thanks for response. I have already solved my problem there: http://stackoverflow.com/questions/37786956/media-source-extensions-appendbuffer-of-webm-stream-in-random-order – lukyer Jun 17 '16 at 08:00