xevojapan / h264-converter

MIT License
59 stars 14 forks source link

Export sourceBuffer. Create initSegment's #10

Closed drauggres closed 3 years ago

drauggres commented 3 years ago

Hi. I use this project in ws-scrcpy to display smartphone screen in a web browser.

  1. For a long session it is possible to use all available memory, so I need to be able to remove data from SourceBuffer.
const converter = new VideoConverter(tag, fps, fpf);

// later, when we know we have too much data buffered
if (!converter.sourceBuffer.updating) {
    converter.sourceBuffer.remove(start, end);
}
  1. When device is rotated, I receive SPS frame with new dementions. To handle changes I need: 2.1. Parse each SPS & PPS 2.2. Create initSegment's for each IDR frame

Also in Safari video rendering will stop, if you remove last initSegment, i.e. we can't remove segments from SourceBuffer in Safari in the current version (because VideoConverter creates only one initSegment).

refs https://github.com/NetrisTV/ws-scrcpy/issues/111

horiuchi commented 3 years ago

@drauggres Thank you for your contribution!