core icon indicating copy to clipboard operation
core copied to clipboard

Seems like V3 is not friendly with large files and higher resolutions.

Open kasralodgy opened this issue 8 months ago • 0 comments

I recently switched to V3 and Using videos that over 1920x1080 will make the core to just block processing without any meaningful error or anything (I am using the simple example, HTML web version, no puppeteer, just pure google chrome with these flags enabled on linux: google-chrome --user-data-dir=./browser_profile --remote-debugging-port=1502 --no-sandbox --enable-unsafe-webgpu --enable-features=Vulkan . Worth mentioning here that if I do not enable --no-sandbox then it will crash in an Aww Snap! error and will not work at all ...).
I fixed the issue by converting 4K videos to 1080p and using them in composition.

But the other day that I was trying to import a 2GB 1080p video file and just trying to add some audio clips to it, It actually corrupts the video output, The first 5 minutes of the video has no sound and the second 5 minutes have sound but the video is stuck at some random frame.

const source_files_audio = [
  await core.Source.from<core.AudioSource>("/Ken.mp3"),
  await core.Source.from<core.AudioSource>("/Dyalla.mp3"),
 ... // 10 more ...
]

const source_file_footage = await core.Source.from<core.VideoSource>('/raw-footage.mp4')

const filledDimension = calculateFilledDimension(source_file_footage) // Just a function I've made, calculates the dimensions that can fill the composition.

await composition.add(new core.VideoClip(source_file_footage, {
  width: filledDimension.width,
  height: filledDimension.height,
}))

{
  // The background music part
  const volume = 0.10
  let total_video_duration = gds(source_file_footage) // gds = get duration seconds.
  if (gds(source_files_audio[0]) > total_video_duration) {
    await composition.add(new core.AudioClip(source_files_audio[0], {
      duration: new core.Timestamp(undefined, total_video_duration),
      volume: volume
    }))
  } else {
    let media_index = 0
    let cumulative_duration = 0
    while (true) {
      const source_file = source_files_audio[media_index % source_files_audio.length]
      media_index += 1
      if (cumulative_duration + gds(source_file) > total_video_duration) {
        await composition.add(new core.AudioClip(source_file, {
          delay: new core.Timestamp(undefined, cumulative_duration),
          duration: new core.Timestamp(undefined, total_video_duration - cumulative_duration),
          volume: volume
        }))
        break // the end audio file.
      } else {
        await composition.add(new core.AudioClip(source_file, {
          delay: new core.Timestamp(undefined, cumulative_duration),
          volume: volume
        }))
        cumulative_duration += gds(source_file)
      }
    }
  }
}

The footage is taken using phone camera in 4K mode and then converted to 1080p using ffmpeg ffmpeg -i input.mp4 -vf scale=1920:1080 -c:a copy output.mp4.

kasralodgy avatar Mar 31 '25 13:03 kasralodgy