How to fix error: Failed to execute ‘endOfStream’ on ‘MediaSource’: The MediaSource’s readyState is not ‘open’


Example you use code here: https://github.com/nickdesaulniers/netfix/blob/gh-pages/demo/bufferAll.html

And you get the error:

Uncaught DOMException: Failed to execute 'endOfStream' on 'MediaSource': The MediaSource's readyState is not 'open'.
    at SourceBuffer.<anonymous>

mp4info your file example:

D:\ffmpeg>D:\mp4\bin\mp4info "D:\AppServ\www\node\mp4box\frag_bunny.mp4"
File:
  major brand:      mp42
  minor version:    0
  compatible brand: isom
  compatible brand: mp42
  fast start:       yes

Movie:
  duration:   1985583 ms
  time scale: 600
  fragments:  no

Found 2 Tracks
Track 1:
  flags:        15 ENABLED IN-MOVIE IN-PREVIEW
  id:           1
  type:         Video
  duration: 1985500 ms
  language: und
  media:
    sample count: 59309
    timescale:    30
    duration:     59565 (media timescale units)
    duration:     1985500 (ms)
    bitrate (computed): 256.343 Kbps
  display width:  640.000000
  display height: 360.000000
  frame rate (computed): 29.871
  Sample Description 0
    Coding:      avc1 (H.264)
    Width:       640
    Height:      360
    Depth:       24
    AVC Profile:          66 (Baseline)
    AVC Profile Compat:   c0
    AVC Level:            30
    AVC NALU Length Size: 4
    AVC SPS: [6742c01eda0280bfe5c05a808080a0000003002000000781e2c5d4]
    AVC PPS: [68ce3c80]
    Codecs String: avc1.42C01E
Track 2:
  flags:        1 ENABLED
  id:           2
  type:         Audio
  duration: 1985583 ms
  language: eng
  media:
    sample count: 85512
    timescale:    44100
    duration:     87564288 (media timescale units)
    duration:     1985585 (ms)
    bitrate (computed): 96.002 Kbps
  Sample Description 0
    Coding:      mp4a (MPEG-4 Audio)
    Stream Type: Audio
    Object Type: MPEG-4 Audio
    Max Bitrate: 103520
    Avg Bitrate: 96000
    Buffer Size: 464
    Codecs String: mp4a.40.2
    MPEG-4 Audio Object Type: 2 (AAC Low Complexity)
    MPEG-4 Audio Decoder Config:
      Sampling Frequency: 44100
      Channels: 2
    Sample Rate: 44100
    Sample Size: 16
    Channels:    2

You don’t see “duration with fragments”.

You must use mp4fragment to change your mp4 file:

D:\ffmpeg>D:\mp4\bin\mp4fragment "D:\AppServ\www\node\mp4box\frag_bunny.mp4" "D:
\AppServ\www\node\mp4box\frag_bunny2.mp4"
found regular I-frame interval: 462 frames (at 29.871 frames per second)

Now your mp4info here:

D:\ffmpeg>D:\mp4\bin\mp4info "D:\AppServ\www\node\mp4box\frag_bunny2.mp4"
File:
  major brand:      mp42
  minor version:    0
  compatible brand: isom
  compatible brand: mp42
  compatible brand: iso5
  fast start:       yes

Movie:
  duration:   1985583 ms
  time scale: 1000
  fragments:  yes

Found 2 Tracks
Track 1:
  flags:        7 ENABLED IN-MOVIE IN-PREVIEW
  id:           1
  type:         Video
  duration: 1985500 ms
  language: und
  media:
    sample count: 0
    timescale:    30
    duration:     0 (media timescale units)
    duration:     0 (ms)
    bitrate (computed): 256.343 Kbps
    sample count with fragments: 59309
    duration with fragments:     59565
    duration with fragments:     1985500 (ms)
  display width:  640.000000
  display height: 360.000000
  Sample Description 0
    Coding:      avc1 (H.264)
    Width:       640
    Height:      360
    Depth:       24
    AVC Profile:          66 (Baseline)
    AVC Profile Compat:   c0
    AVC Level:            30
    AVC NALU Length Size: 4
    AVC SPS: [6742c01eda0280bfe5c05a808080a0000003002000000781e2c5d4]
    AVC PPS: [68ce3c80]
    Codecs String: avc1.42C01E
Track 2:
  flags:        7 ENABLED IN-MOVIE IN-PREVIEW
  id:           2
  type:         Audio
  duration: 1985583 ms
  language: eng
  media:
    sample count: 0
    timescale:    44100
    duration:     0 (media timescale units)
    duration:     0 (ms)
    bitrate (computed): 96.002 Kbps
    sample count with fragments: 85512
    duration with fragments:     87564288
    duration with fragments:     1985585 (ms)
  Sample Description 0
    Coding:      mp4a (MPEG-4 Audio)
    Stream Type: Audio
    Object Type: MPEG-4 Audio
    Max Bitrate: 103520
    Avg Bitrate: 96000
    Buffer Size: 464
    Codecs String: mp4a.40.2
    MPEG-4 Audio Object Type: 2 (AAC Low Complexity)
    MPEG-4 Audio Decoder Config:
      Sampling Frequency: 44100
      Channels: 2
    Sample Rate: 44100
    Sample Size: 16
    Channels:    2

mp4info

Leave a Reply