Skip to content

Render Video Frame to PixiJS Canvas from Uint8Array returned by ffmpeg #448

Discussion options

You must be logged in to vote

I found the answer myself. Thanks. Need to test the efficiency.

const renderFrameToPixi = useCallback(async ({ target: { files } }: any) => {
const { name } = files[0];

ffmpeg.FS("writeFile", name, await fetchFile(files[0]));

await ffmpeg.run("-i", name,"-frames:v" ,"1" , "-vf", `scale=640x360`,"frame.bmp");


 const uint8array = ffmpeg.FS("readFile", `frame.bmp`);
 const bmp = await createImageBitmap(new Blob([uint8array]));
 
let sprite = new PIXI.Sprite(PIXI.Texture.from(bmp));
pixiApp.current?.stage.addChild(sprite); 

}, []);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by SenthilKumaranC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant