@glissade/export-web 0.6.0 → 0.7.0-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +6 -5
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ALL_FORMATS, AudioBufferSource, AudioSample, AudioSampleSource, BlobSource, BufferTarget, CanvasSink, CanvasSource, Input, Mp4OutputFormat, Output, UrlSource, WebMOutputFormat, getFirstEncodableAudioCodec, getFirstEncodableVideoCodec } from "mediabunny";
2
- import { compileTimeline, sampleTrack } from "@glissade/core";
2
+ import { audioOffsetSamples, compileTimeline, sampleTrack } from "@glissade/core";
3
3
  import { ColdAssetError, evaluate } from "@glissade/scene";
4
4
  import { Canvas2DBackend } from "@glissade/backend-canvas2d";
5
5
  //#region src/videoSource.ts
@@ -216,6 +216,7 @@ async function mixAudio(clips, duration, sampleRate = 48e3) {
216
216
  const ctx = new OfflineAudioContext(2, Math.ceil(duration * sampleRate), sampleRate);
217
217
  for (const clip of clips) {
218
218
  if (clip.at >= duration) continue;
219
+ const startAt = audioOffsetSamples(clip.at, sampleRate) / sampleRate;
219
220
  const resp = await fetch(clip.asset.url);
220
221
  if (!resp.ok) throw new Error(`audio asset fetch failed (${resp.status}): ${clip.asset.url}`);
221
222
  const decoded = await ctx.decodeAudioData(await resp.arrayBuffer());
@@ -231,16 +232,16 @@ async function mixAudio(clips, duration, sampleRate = 48e3) {
231
232
  type: "number",
232
233
  keys
233
234
  };
234
- gainNode.gain.setValueAtTime(Number(keys[0].value), Math.max(0, clip.at));
235
- for (const k of keys) gainNode.gain.linearRampToValueAtTime(Number(sampleTrack(gainTrack, k.t)), clip.at + k.t);
235
+ gainNode.gain.setValueAtTime(Number(keys[0].value), Math.max(0, startAt));
236
+ for (const k of keys) gainNode.gain.linearRampToValueAtTime(Number(sampleTrack(gainTrack, k.t)), startAt + k.t);
236
237
  tail.connect(gainNode);
237
238
  tail = gainNode;
238
239
  }
239
240
  tail.connect(ctx.destination);
240
241
  const offset = clip.trim?.start ?? 0;
241
242
  const sourceDur = clip.trim ? clip.trim.end - clip.trim.start : void 0;
242
- if (sourceDur !== void 0) node.start(Math.max(0, clip.at), offset, sourceDur);
243
- else node.start(Math.max(0, clip.at), offset);
243
+ if (sourceDur !== void 0) node.start(Math.max(0, startAt), offset, sourceDur);
244
+ else node.start(Math.max(0, startAt), offset);
244
245
  }
245
246
  return ctx.startRendering();
246
247
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissade/export-web",
3
- "version": "0.6.0",
3
+ "version": "0.7.0-pre.0",
4
4
  "description": "glissade in-browser export: WebCodecs VideoEncoder + Mediabunny muxing, OfflineAudioContext audio mix. Frame-accurate, faster than realtime, no server.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -16,9 +16,9 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "mediabunny": "^1.0.0",
19
- "@glissade/backend-canvas2d": "0.6.0",
20
- "@glissade/core": "0.6.0",
21
- "@glissade/scene": "0.6.0"
19
+ "@glissade/backend-canvas2d": "0.7.0-pre.0",
20
+ "@glissade/scene": "0.7.0-pre.0",
21
+ "@glissade/core": "0.7.0-pre.0"
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",