Skip to content

Cannot load video composition when there're too many clips #63

@whentao

Description

@whentao

Hey Diffusion studio team, thank you for the amazing work.

I got an error for many clips and doesn't find any way to get around with it.

When there're many clips, the composition will crash at one certain number based on the file size, even though I only take 1 frame for the clip. For example,

const composition = new core.Composition({ background: "#76b7f5" });

setupControls(composition);
setupTimeline(composition);
const videoSource = await core.VideoSource.from("/video1.mp4");

for (let i = 0; i < 200; i++) {
  console.log("goto:", i);
  const videoClip = await composition.add(
    new core.VideoClip(videoSource, {
      position: "center",
      height: "100%",
      muted: true,
    }).subclip(0, 1)
  );
}

My video size is 78MB. This logic would always throw error at i == 128 no matter how many frames I take into clips. The error is

MediaError {code: 4, message: 'DECODER_ERROR_NOT_SUPPORTED: video decoder initial…led with DecoderStatus::Codes::kUnsupportedConfig'}
code : 4
message : "DECODER_ERROR_NOT_SUPPORTED: video decoder initialization failed with DecoderStatus::Codes::kUnsupportedConfig"

After some testing from my side, one possible reason is that, the browser element could only hold a certain size of video cache. Since I tried the following logic

for (let i = 0; i < 100; i++) {
  ....
}

composition.removeTracks(core.Track);
composition.removeTracks(core.VideoTrack);

await delay(5000);

for (let i = 0; i < 100; i++) {
  ....
}

This doesn't solve the crash. I have to manually clean up video element using this code inside video clip when removeTracks to avoid the error. If I don't reset the src, the error doesn't go away.

  public removeSelf(): void {
    this.element.removeAttribute("src");
    this.element.load();
    this.element.src = "";
    this.element.srcObject = null;
    this.element.remove();
  }

Any ideas to reuse as any as possible about the video element?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions