Video Art: Experimental Animation and Video Techniques in Linux
There are several ways to turn frames into motion via the command line.
jpegtoavi is a simple C script that does exactly what its name
suggests—converts a sequence of *.jpg files into an AVI movie. If your
images are not in the JPEG format, you first can convert them using the
convert command from ImageMagick:
convert image.png image.jpg
If you need to convert a batch of images in a folder, ImageMagick
grants you about a gazillion different methods. One of these is to
cd to that directory and do:
convert *.png image.jpg
The new filenames will be numbered automatically.
Once you have your folder of sequenced JPEG files, you can employ jpegtoavi. A basic usage template from the man page is:
jpegtoavi -f fps width height img1 [img2 ... imgN]
Although jpegtoavi is nice for simple tasks, minimal documentation exists. I was surprised to find that none of the main Web sites hosting downloads of the software provided any type of wiki or instructions beyond what already was in the man page and README.
You can do more-advanced encoding with FFmpeg and MEncoder, both of which are heavily documented on-line and in their man pages. These programs both rely on libavcodec and have many overlapping uses, but the command formats are different. For this article, I cover only FFmpeg.
This will convert a folder of GIF files sequenced as "image-001", "image-002" and so forth into an MP4 movie file with a framerate of 10 frames per second and a reasonably high bitrate of 1800:
ffmpeg -r 10 -b 1800 -i image-%03d.gif movie.mp4
Make sure your files are named properly, because encoding will stop early if the program encounters a gap in the number sequence.
If you're a citizen of the Internet, you've no doubt noticed the recent proliferation of animated GIFs on sites like Tumblr.com. Now that more people have access to high-bandwidth network connections, the GIF art form is not so limited in resolution and number of frames as it was in the 1990s when tiny GIF animations originally rose to popularity in Geocities and Angelfire home pages. Modern GIF animations often display entire scenes from movies.
So, are you ready to pimp out some mad GIF skills?
With ImageMagick, it's easy to fashion an animated GIF from a sequence of non-GIF images:
cd /path/to/image/folder ; convert *.jpg animation.gif
The mother of all command-line GIF manipulation programs though is Gifsicle. Your images must already be in the GIF format to use it.
To create a GIF that animates just once, do:
gifsicle image1.gif image2.gif image3.gif > animation.gif
In most cases, you'll want your animated GIF to loop endlessly. You also may want to specify parameters, such as framerate. Try this for a dithered animation that loops at 10 frames per second:
gifsicle --loopcount=0 --delay 10 --dither image1.gif image2.gif image3.gif > animation.gif
You also can use Gifsicle in reverse mode—that is, to extract
the individual frames from an animated GIF. Just use the
gifsicle --explode animation.gif
Now, go out (and by "out", I mean to your nearest terminal) and explore all the neat tricks you can do with Gifsicle!
Here's one more to wet your feet:
Take a ready-made animated GIF with a white background and make it transparent:
gifsicle --transparent '#FFFFFF' --disposal 2 animation.gif > animation-transparent.gif
Rebecca "Ruji" Chapnik is a freelance creator of miscellanea, including but not limited to text and images. You can find her experiments at http://rujic.net
Getting Started with DevOps - Including New Data on IT Performance from Puppet Labs 2015 State of DevOps Report
August 27, 2015
12:00 PM CDT
DevOps represents a profound change from the way most IT departments have traditionally worked: from siloed teams and high-anxiety releases to everyone collaborating on uneventful and more frequent releases of higher-quality code. It doesn't matter how large or small an organization is, or even whether it's historically slow moving or risk averse — there are ways to adopt DevOps sanely, and get measurable results in just weeks.
Free to Linux Journal readers.Register Now!
- Django Models and Migrations
- Hacking a Safe with Bash
- Secure Server Deployments in Hostile Territory, Part II
- Huge Package Overhaul for Debian and Ubuntu
- The Controversy Behind Canonical's Intellectual Property Policy
- Home Automation with Raspberry Pi
- Shashlik - a Tasty New Android Simulator
- Embed Linux in Monitoring and Control Systems
- KDE Reveals Plasma Mobile
- diff -u: What's New in Kernel Development