Skip to content

Commit

Permalink
Merge pull request #26 from VisActor/feat-vmind-getBuffer
Browse files Browse the repository at this point in the history
Feat vmind get buffer
  • Loading branch information
da730 authored Feb 7, 2024
2 parents b984879 + df99d93 commit 25dc339
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
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

0 comments on commit 25dc339

Please sign in to comment.