ffmpegwasm / ffmpeg.wasm

FFmpeg for browser, powered by WebAssembly
https://ffmpegwasm.netlify.app
MIT License
14.56k stars 858 forks source link

How to stream images to ffmpeg to create a video #155

Closed yaakov123 closed 3 years ago

yaakov123 commented 3 years ago

This isn't really a bug, but more of a question. In the example provided in image2video.html all the images are created before running ffmpeg. I was wondering if there was a way to stream the images to ffmpeg as they are created. My use case here is that I would like to create images from canvas and would like to progressively add the images to ffmpeg as they are rendered to the canvas.

bbudd commented 3 years ago

You shouldn't need to use FFMpeg at all, unless you're changing the canvas very slowly. You probably just want the media recorder api. If FFMpeg were to be used at all, it might be used for converting the mediarecorder output to a format unavailable to the browser.

yaakov123 commented 3 years ago

I would like to be able to combine other video files along with the output of the canvas. Something like this: .mp4 video + canvas-video + .mp4 video and media recorder gives me a webm video which means I would have to transcode the webm video to mp4 in order to combine it with the existing video. So I would like a solution using only ffmpeg with images.

bbudd commented 3 years ago

you would still do better with video, then if you wanted bumpers you could prepend/append them via ffmpeg, which should not have any problem at all merging the 3 videos into a new one, regardless of the container of any single piece. And it would still be a lot faster than creating images and converting those to a movie.

yaakov123 commented 3 years ago

First of all thanks for taking the time to reply, however, I'm not really understanding what you're saying. Regardless, the question was if there was a way to progressively add images to ffmpeg as they're being rendered to the canvas. Is there a way to do that or not?

cjbarth commented 3 years ago

Did you want to add them while compression is on-going, or are you ok adding them all ahead of time and then compressing?

snuffysasa commented 2 years ago

I am wondering how to do this as well. I have image frames on a server that I want to on demand convert to video and sent to client.

I want to something like this ffmpeg -framerate 10 -pattern_type glob -I "image_folder/*.jpeg" test.mp4

howtomakeaturn commented 8 months ago

I'm facing a similar situation. media recorder api works great for me.

Thanks @bbudd for mentioning it!