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

Feat vmind get buffer #26

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/vmind/__tests__/browser/src/pages/ChartPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ export function ChartPreview(props: IPropsType) {
log: true
});
await ffmpeg.load();
const src = await vmind.exportVideo(spec, time, {
const data = await vmind.exportVideo(spec, time, {
VChart,
FFmpeg: ffmpeg,
fetchFile,
ManualTicker,
defaultTimeline,
createCanvas
} as any);
const src = URL.createObjectURL(new Blob([data], { type: 'video/mp4' }));
setSrc(src);
setOutType('video');
setGenerating(false);
Expand All @@ -84,14 +85,15 @@ export function ChartPreview(props: IPropsType) {
log: true
});
await ffmpeg.load();
const src = await vmind.exportGIF(spec, time, {
const data = await vmind.exportGIF(spec, time, {
VChart,
FFmpeg: ffmpeg,
fetchFile,
ManualTicker,
defaultTimeline,
createCanvas
} as any);
const src = URL.createObjectURL(new Blob([data], { type: 'video/mp4' }));
setSrc(src);
setOutType('gif');
setGenerating(false);
Expand Down
6 changes: 2 additions & 4 deletions packages/vmind/src/core/VMind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ class VMind {
const outName = `out`;
await _chatToVideoWasm(this._FPS, spec, time, outName, outerPackages);
const data = FFmpeg.FS('readFile', `${outName}.mp4`);
const objUrl = URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' }));
return objUrl;
return data.buffer;
}

async exportGIF(spec: any, time: TimeType, outerPackages: OuterPackages) {
Expand All @@ -121,8 +120,7 @@ class VMind {
'out.gif'
);
const data = FFmpeg.FS('readFile', 'out.gif');
const objUrl = URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' }));
return objUrl;
return data.buffer;
}
}

Expand Down
Loading