question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generating movie from images in memory

See original GitHub issue

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!)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:11

github_iconTop GitHub Comments

6reactions
danvoycecommented, Dec 5, 2019

Yes you are right. After some digging I found you can use %d instead which solves my issue, so now I’m using

-framerate ${fps} -i /data/%d.jpg -s ${width}x${height} -c:v libx264 -pix_fmt yuv420p out.mp4

Again thanks so much, this is a game changer for me. I seriously owe you a beer!

2reactions
boraturantcommented, Apr 1, 2020

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: could find no file with path ‘/data/img_%04d.jpg’ and index in the range 0-4

I can read the file with the worker.read method.

//For loop

var dataURL = this.canvas.toDataURL('image/jpeg', 1);

await worker.write( `img_${String(frameNo).padStart(4, '0')}.jpg`,
				dataURL
			       );
frameNo++;
//End loop

await worker.run(
			'-framerate 30 -start_number 0  -i /data/img_%04d.jpg  -c:v libx264 out.mp4',
			{
				outputPath: 'out.mp4'
			}
);



Read more comments on GitHub >

github_iconTop Results From Across the Web

Create Meaningful Memories Photo Videos for Free - FlexClip
FlexClip's free memories photo video maker is the perfect tool to turn your memories photos to a telling video or slideshow fast online...
Read more >
Use Memories in Photos on your iPhone, iPad, or iPod touch
Go to the Albums tab, then tap the People album. Tap the thumbnail of the person, then tap the More button . Tap...
Read more >
Memorial Video Maker | Create a Tribute Video Free - Animoto
Create a beautiful tribute video with Animoto's free memorial video maker. Easily turn photos, video clips, and music into a memorial slideshow.
Read more >
How to Use Apple's Photos App to Quickly Create a Memory ...
Apple's Photos app on a Mac contains the powerful functionality to organize your pictures into collections and then display them as “Memory ......
Read more >
Create Animated Digital Memories - GoodTrust
Create digital memories. ; Send a video or letter to the future days, weeks, or years from now.Send Message ; Upload a photo,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found