-
-
Notifications
You must be signed in to change notification settings - Fork 852
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
Generating movie from images in memory #9
Comments
I would recommend you start from this example: https://github.com/ffmpegjs/ffmpeg.js/blob/master/examples/browser/image2video.html I think it includes key steps you need to achieve your scenario, a trap (?) here is that when you write an image file with Worker.write(), this image actually saves under A quick snippet for your reference (without verification): const cnt = 0;
const b64Image = thumbnailCanvas.toDataURL('image/jpeg', 1);
await worker.write(`thumbnail_${cnt++}.jpg`, b64Image);
await worker.run('-framerate 30 -pattern_type glob -i /data/thumbnail_*.jpg -c:a copy -shortest -c:v libx264 -pix_fmt yuv420p out.mp4', { outputPath: 'out.mp4' });
const { data } = await worker.read('out.mp4');
for (let i = 0; i < cnt; i++) {
await worker.remove(`thumbnail_${i}.jpg`);
} |
I think the issue here is about the naming of the images, you need to add padding zeros in the sequence number. So instead of thumbnail_1.jpg, using thumbnail_01.jpg is a better option. |
Yes you are right. After some digging I found you can use
Again thanks so much, this is a game changer for me. I seriously owe you a beer! |
That method works, and this is awesome! |
I don't think it is possible to use image2pipe at the moment as it requires Linux pipeline syntax which is not possible to achieve at the moment. I think the best bet so far is to produce multiple video files with certain amount of images and concat them together. |
Hi, This method doesn't seem to be working now. Has there been any change where the files are stored? (/Data/) or any other mechanics? Error: I can read the file with the worker.read method.
|
I followed this guide but ffmpeg.js does not seem to be able to read the files written: |
You can check this example: https://github.com/ffmpegjs/ffmpeg.js/blob/master/examples/browser/image2video.html |
await worker.write(`thumbnail_${cnt++}.jpg`, b64Image); where does |
Did this broke? |
I'm trying to convert a Canvas animation into a video. As the animation may not run at 60fps I'm thinking I want to create a still image of each frame like so
thumbnailCanvas.toDataURL('image/jpeg', 1);
and then stitch them all back together to make the video.
As I want this to run completely client side, I don't have the option of creating a temp
/images
folder and iterating over that.Is this possible with ffmpeg.js? I've been playing around with
worker.run(...
but can't seem to figure out the correct arguments and options.Thanks for any help (and awesome lib btw!)
The text was updated successfully, but these errors were encountered: