Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
whentao opened this issue Jan 7, 2025 · 1 comment
Open

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

whentao opened this issue Jan 7, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@whentao
Copy link
Contributor

whentao commented Jan 7, 2025

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?

@whentao whentao changed the title Cannot load video when there're too many clips Cannot load video composition when there're too many clips Jan 7, 2025
@k9p5
Copy link
Contributor

k9p5 commented Feb 4, 2025

Hey! Thanks for reaching out.

Try V2, just released—it includes major improvements in memory management and should fix this issue. Let us know if you need any help!

@k9p5 k9p5 added the bug Something isn't working label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants