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

Can't read an image layer while rendering the movie. The image is from remote, like (https://image/) #265

Open
Ziputrafa opened this issue Feb 21, 2024 · 2 comments
Labels
help wanted Extra attention is needed priority:high type:bug Something isn't working

Comments

@Ziputrafa
Copy link

I'm using etro in nextjs. when I want to render a movie with an image layer (remote image file). it doesn't work. but It works when I render a movie with an image layer (local image file).

'use client';
import etro from 'etro';
import { useEffect, useRef } from 'react';
import './editor.css';
import { saveAs } from 'file-saver';

const Editor = () => {
const canvasRef = useRef<HTMLCanvasElement | null>(null);
const imageRef = useRef<HTMLImageElement | null>(null);
const movieRef = useRef<any>(null);

useEffect(() => {
const movie = new etro.Movie({
canvas: canvasRef.current,
background: etro.parseColor('gold'),
});

const localImageLayer = new etro.layer.Image({
startTime: 2,
duration: 2,
source: imageRef.current,
});
const remoteImageLayer = new etro.layer.Image({
startTime: 4,
duration: 1,
source: 'https://images.pexels.com/photos/2014422/pexels-photo-2014422.jpeg?``auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200',
});
movie.addLayer(remoteImageLayer); // render only a gold layer which is the movie background

movieRef.current = movie;
}, []);

const download = async () => {
if (movieRef.current) {
try {
await movieRef.current.stop();
const blob = await movieRef.current.record({
frameRate: 30,
});
await saveAs(blob, 'theVideo.mp4'); // render a video from the blob
} catch (error) {
console.error(error);
}
}
};
return (
<>
<button onClick={download}>download</button>
<canvas ref={canvasRef} />
<img ref={imageRef} src="./assets/photo.jpg" />
</>
);
};

export default Editor;

movie.addLayer(localImageLayer); will render a video with the image layer. but movie.addLayer(remoteImageLayer) will render a video with only contains a gold screen which is the movie background.

@clabe45
Copy link
Collaborator

clabe45 commented Mar 3, 2024

Hi @Ziputrafa, are there any errors in the console or failed network requests?

@clabe45 clabe45 added type:bug Something isn't working priority:medium labels Mar 3, 2024
@oceansam
Copy link

Ran into this issue as well for remote images.

No network or console errors. The blob does appear on the network
blob:https://... however, .record never resolves and doesn't call its then clause.

@clabe45 clabe45 added help wanted Extra attention is needed priority:high and removed priority:medium labels Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed priority:high type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants