I am trying to use FFMpeg to take a stream of image files and turn them into a video. Now, I have successfully done this, but only after I have already captured all the images that I want. What I would like to do is turn the images into a video as they are saved to disk (real-time video recorder). Currently, when I call FFMpeg while frames are still being grabbed, it only encodes the number of images that are present when it is called. If FFMpeg is called every time an image is grabbed, it floods the CPU with a ton of processes. Ideally, FFMpeg would continue to encode the images until there are no more images being captured (I.E., check if there are more image files since it was first called). Is there an argument for FFMpeg that I'm missing, or is this not possible? Or is the only way to do this through messing around with the libraries?
Asked
Active
Viewed 3,508 times
5
-
What video format are you targeting? not all formats support encoding like this. What are you planning on doing about key frames? is the time between images related to the length of the video or are you creating some kind of time lapse? – Jeff May 03 '12 at 23:45
-
I was originally planning on avi, but really any widely used format would work fine. Right now, I'm grabbing images 25 times per second (25 fps), so that it can easily make a 25 fps video from them, which plays the encoded video as it appeared in real time. Currently, my key frames are forced every 1 second of video (every 25 frames). – Ben May 04 '12 at 02:11
1 Answers
1
One solution but not one I like is: Encode a base video in Mpeg2 VOB. Every X frames encode a new video of the last X frames. As VOB files have no file headers you can them just append the binary of the new file to the existing VOB. FFMPEG would only need to run on a few frames. Some other video formats might work too.

Jeff
- 4,622
- 2
- 27
- 40
-
Looked into something along these lines, but FFMpeg can't encode from a random number in an image sequence (I.E., it always has to start at img000; not img405...). As a result, the best you can get it to do in this scenario is to rename the image sequence every time you call ffmpeg, so that they start at 0 again, and then add on the subsequent .vob it creates every time it gets through a certain number of images. This isn't practical for real-time encoding, as it spawns a lot of processes and can't do all this quickly enough. – Ben May 08 '12 at 18:29
-
I would have just moved the processed files to a different directory after I was done with them. – Jeff May 11 '12 at 20:54