Release Timeline Studio v0.4.0
This commit is contained in:
1 parent
2b9a1e7e0b
commit
7076e005af
66 files changed
+2246
-545
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("offline export restores enabled embedded video audio when no separated source track exists", async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
await page.goto("/");
|
||||
const result = await page.evaluate(async () => {
|
||||
const [{ exportOfflineVideo }, { prepareEmbeddedVideoAudio }] = await Promise.all([
|
||||
import("/src/lib/offlineVideoExport.js"),
|
||||
import("/src/lib/embeddedVideoAudioExport.js"),
|
||||
]);
|
||||
const canvas = document.createElement("canvas"); canvas.width = 160; canvas.height = 90;
|
||||
const context = canvas.getContext("2d"); context.fillStyle = "#254fd4"; context.fillRect(0, 0, 160, 90);
|
||||
const image = canvas.toDataURL("image/png");
|
||||
const sampleRate = 48_000; const frames = sampleRate / 2;
|
||||
const wav = new ArrayBuffer(44 + frames * 2); const view = new DataView(wav);
|
||||
const write = (offset, value) => [...value].forEach((char, index) => view.setUint8(offset + index, char.charCodeAt(0)));
|
||||
write(0, "RIFF"); view.setUint32(4, 36 + frames * 2, true); write(8, "WAVEfmt ");
|
||||
view.setUint32(16, 16, true); view.setUint16(20, 1, true); view.setUint16(22, 1, true);
|
||||
view.setUint32(24, sampleRate, true); view.setUint32(28, sampleRate * 2, true);
|
||||
view.setUint16(32, 2, true); view.setUint16(34, 16, true); write(36, "data"); view.setUint32(40, frames * 2, true);
|
||||
for (let index = 0; index < frames; index += 1) view.setInt16(44 + index * 2, Math.sin(index / sampleRate * Math.PI * 2 * 440) * 9000, true);
|
||||
const voice = new Blob([wav], { type: "audio/wav" });
|
||||
const source = await exportOfflineVideo({
|
||||
imageSrc: image, visualType: "image", visualSegments: [{ id: "image", src: image, type: "image", duration: 0.5 }],
|
||||
voiceAudioSegments: [{ id: "voice", blob: voice, start: 0, duration: 0.5, volume: 1 }],
|
||||
sourceAudioBlob: null, sourceAudioSegments: [], musicBlob: null, text: "", captionSegments: [],
|
||||
duration: 0.5, ratio: { width: 16, height: 9 }, fitMode: "cover", filter: "none", captionsEnabled: false,
|
||||
captionSize: 12, captionStyle: {}, captionReferenceSize: { width: 160, height: 90 }, stickerSegments: [],
|
||||
exportSettings: { codec: "vp9", width: 160, height: 90, frameRate: 24, videoBitsPerSecond: 800_000 },
|
||||
});
|
||||
const sourceUrl = URL.createObjectURL(source.blob);
|
||||
const visuals = [{ id: "video", assetId: "video-asset", name: "source.webm", src: sourceUrl, blob: source.blob, type: "video", duration: 0.5, sourceStart: 0, sourceDuration: 0.5, playbackRate: 1 }];
|
||||
const embedded = await prepareEmbeddedVideoAudio(visuals);
|
||||
const exported = await exportOfflineVideo({
|
||||
imageSrc: sourceUrl, visualType: "video", visualSegments: visuals,
|
||||
voiceAudioSegments: [], sourceAudioBlob: embedded.blob, sourceAudioSegments: embedded.segments,
|
||||
musicBlob: null, text: "", captionSegments: [], duration: 0.5, ratio: { width: 16, height: 9 },
|
||||
fitMode: "cover", filter: "none", captionsEnabled: false, captionSize: 12, captionStyle: {},
|
||||
captionReferenceSize: { width: 160, height: 90 }, stickerSegments: [],
|
||||
exportSettings: { codec: "vp9", width: 160, height: 90, frameRate: 24, videoBitsPerSecond: 800_000 },
|
||||
});
|
||||
const audioContext = new AudioContext();
|
||||
const decoded = await audioContext.decodeAudioData((await exported.blob.arrayBuffer()).slice(0));
|
||||
await audioContext.close(); URL.revokeObjectURL(sourceUrl);
|
||||
return { duration: decoded.duration, samples: decoded.length, segmentCount: embedded.segments.length, size: exported.blob.size };
|
||||
});
|
||||
expect(result.segmentCount).toBe(1);
|
||||
expect(result.duration).toBeGreaterThan(0.45);
|
||||
expect(result.samples).toBeGreaterThan(20_000);
|
||||
expect(result.size).toBeGreaterThan(2_000);
|
||||
});
|
||||
@@ -18,6 +18,9 @@ test("offline export preserves stickers, captions, voice audio, dimensions and d
|
||||
context.clearRect(0, 0, 320, 180);
|
||||
context.fillStyle = "#00ffff"; context.fillRect(120, 50, 80, 80);
|
||||
});
|
||||
const overlay = makeImage((context, canvas) => {
|
||||
context.fillStyle = "#246bff"; context.fillRect(0, 0, canvas.width, canvas.height);
|
||||
});
|
||||
const sampleRate = 48_000;
|
||||
const frames = sampleRate;
|
||||
const wav = new ArrayBuffer(44 + frames * 2);
|
||||
@@ -41,6 +44,7 @@ test("offline export preserves stickers, captions, voice audio, dimensions and d
|
||||
captionReferenceSize: { width: 320, height: 180 },
|
||||
sticker: null,
|
||||
stickerSegments: [{ id: "sticker", src: sticker, start: 0, duration: 1, x: 50, y: 50, scale: 2, opacity: 1 }],
|
||||
visualOverlaySegments: [{ id: "overlay", src: overlay, type: "image", start: 0, duration: 1, layer: 1, keyframes: [{ time: 0, x: 30, y: -25, scale: 0.3, rotation: 0, opacity: 1 }] }],
|
||||
exportSettings: { codec: "vp9", width: 320, height: 180, frameRate: 30, videoBitsPerSecond: 3_000_000 },
|
||||
});
|
||||
const audioContext = new AudioContext();
|
||||
@@ -56,10 +60,11 @@ test("offline export preserves stickers, captions, voice audio, dimensions and d
|
||||
const context = sample.getContext("2d"); context.drawImage(video, 0, 0);
|
||||
const center = [...context.getImageData(160, 90, 1, 1).data];
|
||||
const lower = [...context.getImageData(160, 156, 1, 1).data];
|
||||
const overlayPixel = [...context.getImageData(256, 45, 1, 1).data];
|
||||
const metadata = {
|
||||
width: video.videoWidth, height: video.videoHeight,
|
||||
duration: decodedAudio.duration, hasAudio: decodedAudio.length > 0,
|
||||
mediaDuration: video.duration, center, lower, size: exported.blob.size,
|
||||
mediaDuration: video.duration, center, lower, overlayPixel, size: exported.blob.size,
|
||||
diagnostics: exported.diagnostics,
|
||||
};
|
||||
URL.revokeObjectURL(url);
|
||||
@@ -74,6 +79,7 @@ test("offline export preserves stickers, captions, voice audio, dimensions and d
|
||||
expect(result.center[1]).toBeGreaterThan(result.center[0]);
|
||||
expect(result.center[2]).toBeGreaterThan(result.center[0]);
|
||||
expect(result.lower[0] + result.lower[1] + result.lower[2]).toBeGreaterThan(40);
|
||||
expect(result.overlayPixel[2]).toBeGreaterThan(result.overlayPixel[0]);
|
||||
expect(result.diagnostics.frameCount).toBe(30);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user