Proposed JPEG/JFIF APP0 marker application extension for playback control of concatenated JPEGs as stand-alone animation stream or Motion-JPEG.
This repository provides a reference implementation of the proposed Animated JPEG standard through a collection of routines and helper scripts in Perl. Bundled scripts illustrate how to form a single "animated jpeg file" out of a number of single images, and how to revert this non-destructive process, by allowing a user to extract single images from an "animated jpeg file" and store these frames as individual files again.
An Animated JPEG file is a stream of concatenated individual JPEG files, then representing a frame within the animation. This is similar to the non-standard Motion-JPEG (MJPEG) format, but with additional metadata to control the animation, stored along with the first frame, or each subsequent, added as APP0 marker application data segment.
Why?
Animated JPEG files are more efficient than animated GIFs. That said, the file format described here is simply a concatenation of JPEGs, so there is no inter-frame compression, resulting in lower overall compression in comparison with modern video formats.
Animated JPEG files are very suitable for flip-book like short animations, with low frame-rates. Each frame can have it's own display duration - uncommon or not possible with most video containers.
As adding and removing the control APP0 tag to a JPEG does not trigger a recompression of the actual image data payload, forming an animation, or breaking it into individual files again, is a lossless (no new "generation") JPEG/JFIF transform and non-destructive.
MJPEG commonly has no "playback control" metadata embedded. Frame rate is either set via HTTP header (not available when the stream is not served by a web server) or assumed by the player application (to be a common video frame-rate of about 25fps; try mplayer, avplay, vlc). AJPEG offers a facility to set fps, and current specs define a default of 10 frames-per-second.
Please refer to the Official Specifications for details.
Bundled with this distribution is a reference implementation, written in Perl, Image::Animated::JPEG.
As of version 0.02, the distribution comes with an experimental/wip JavaScript implementation to parse and display AJPEG animations in a browser.
To install this implementation and accompanying scripts, do this on command-line:
wget https://github.com/clipland/animated-jpeg/archive/master.tar.gz
tar xvf master.tar.gz
cd animated-jpeg-master
perl Makefile.PL
make
make test
sudo make install
or, via CPAN:
sudo cpan -i CLIPLAND/Image-Animated-JPEG-0.01.tar.gz
If you'd like to set a MIME-Type for AJPEGs on your system and want to play such files with bundled playajpeg, then there's a .desktop and a .xml file in the /debian directory of this release. For a local install, on Ubuntu/Linux do this:
cp ./debian/image-ajpeg.xml ~/.local/share/mime/packages/image-ajpeg.xml
cp ./debian/playajpeg.desktop ~/.local/share/applications/playajpeg.desktop
update-mime-database ~/.local/share/mime
update-desktop-database ~/.local/share/applications
This is alpha quality software. Do not test it on important data or files.
Related technology:
- Motion-JPEG
- Animated GIF
- Animated PNG, APNG specs
- Multiple-image Network Graphics, MNG
- WebP animation
- AVI container with JPEG codec
Clipland GmbH, clipland.com
Copyright 2013-2019 Clipland GmbH. All rights reserved.
This library is free software, dual-licensed under GPLv3 and Perl Artistic 2. You can redistribute it and/or modify it under the same terms as Perl itself.
AJPEG specifications are licensed to the public under the GNU Free Documentation License (GNU FDL or GFDL) Version 1.3.