Convert a series of PNGs to an animated gif or video file
Solution 1
If you want to convert an image sequence into an animated .gif, the easiest way is via ImageMagick's convert
command:
convert -delay 5 -layers Optimize $FILE_LIST foo.gif
The above command combines all of the files into an optimized animated .gif with a 5 millisecond frame time. You can also do more complicated things with timing via something like:
convert -layers Optimize -delay 5 frame1.png frame2.png -delay 10 frame3.png animation.gif
which gives a 5ms delay for frame1 and frame2, and a 10ms delay for frame3.
Solution 2
If you're concerned about quality, don't convert to GIF.
To create a video, you can use ffmpeg
:
ffmpeg -f image2 -i 'image%d.png' -vcodec copy out.mkv
-f image2 -i 'image%d.png'
tells ffmpeg
to read the PNG images image1.png
, image2.png
, etc. in sequence. -vcodec copy
losslessly stores the images in a video stream. The resulting video is playable in vlc
or totem
.
Since the image data is just copied, this will be very fast and of course lossless.
(See "How do I encode single pictures into movies?" in ffmpeg's docs.)
Related videos on Youtube
HelloCW
Updated on September 18, 2022Comments
-
HelloCW over 1 year
In Android Studio, I can click "Run" button in IDE to run an app, the app is running under debug model, but how can I know there is a debug model programatically? just like the following code.
If (IsDebug()){ Toast.makeText(getApplicationContext(), "This is in debug, it will diplay some prompt information",Toast.LENGTH_LONG).show(); }else{ Toast.makeText(getApplicationContext(), "This is release edition, it will not diplay debug information",Toast.LENGTH_LONG).show(); }
-
Rustam almost 9 years
if (BuildConfig.DEBUG) { // do something for a debug build }
-
-
HelloCW almost 9 yearsThanks! Do you think that Altoyr's way is always OK ?
-
John Thur almost 9 years@HelloCw yes, if you need to customize your own flag, that's a good example. But if you want to use this in library project, you may need some other workaround because there is a bug of
android gradle plugin
mentioned in my reply. -
HelloCW almost 9 yearsThanks, do you mean that I maybe also meet bugs even if I use Altoyr's code?
-
HelloCW almost 9 yearsDo you mean that I also maybe meet bugs even if I use Altoyr's code?