Stacking some images with convert

Today I remembered I was reading on the web, somewhere I don’t remember, someone asked about stacking images that were grabbed from a webcam into one file, to create a kind of ghost effect.

Playing around with ffmpeg and convert I was able to create a little script that captures a frame from /dev/video0, save it as a file, and merge it into some kind of end result: a jpg picture đŸ™‚

# Example of catching a live feed with ffmpeg, and merging the captured images with convert


# We start the loop 
while true; do

# Now we capture the image
ffmpeg -nostats -loglevel 0 -i /dev/video0 -vframes 1 -s 1024x768 -f mjpeg -y jpg-$i.jpg


# We convert to an average 
convert *.jpg -evaluate-sequence mean a.jpg

# We're done, repeat

Ofcourse, convert will take longer and longer to process all the files, but I do this to create the best effect.
Maybe you can even use the convert cmd this way to create star trail pictures, I’ll have to try that one day.

You could keep it simpler, and just capture 2 files, and merge that into one new file, capture a new file it, merge that, etc., but then the ghost  effect dissipates quickly.

It is fun to play around with concepts like these using linux. It is very powerful do be able to do this kind of thing from the command line.

Next time I want to post something about video streams and how to use ffmpeg and ffserver, I’ll keep you posted.

Have fun!

This entry was posted in convert, ffmpeg, linux. Bookmark the permalink.