I have a set of images with me, I wish to run them through a loop , and save it as a video file in sdcard. Is there any default utility in android which I can use. ? Any libraries that can fulfill my requirement. ?
-
http://stackoverflow.com/questions/13643046/how-to-convert-images-into-video-in-android-using-javacv – Venkatesh S Jan 25 '13 at 12:47
-
http://stackoverflow.com/questions/13643046/how-to-convert-images-into-video-in-android-using-javacv Visit the above link ... – Venkatesh S Jan 25 '13 at 12:48
-
@Shishir Shetty ... did you find any solution? – Android dev Feb 04 '19 at 09:39
-
@Androiddev I ended up using https://www.javacodegeeks.com/2011/02/xuggler-tutorial-frames-capture-video.html . . Please note this was like 5 years ago. – Shishir Shetty Feb 05 '19 at 18:44
4 Answers
You need a library for creating these. There are some post here about that:
Tutorial :

- 1
- 1

- 10,669
- 6
- 61
- 96
There is no built in Android
library that supports this functionality. This SO post suggest the use of the ffmpeg
written in C/C++ via a Java port or using the Android NDK
.
Used Java javacpp.jar
and javacv.jar
in your android project to create series of Images to Video
Below Code Use to create video
recorder = new FFmpegFrameRecorder("Videofilename", 480, 480);
try {
recorder.setVideoCodec(13);
recorder.setFrameRate(0.4d);
recorder.setPixelFormat(0);
recorder.setVideoQuality(1.0d);
recorder.setVideoBitrate(4000);
startTime = System.currentTimeMillis();
recorder.start();
int time = Integer.parseInt(params[0]);
resp = "Slept for " + time + " milliseconds";
for (int i = 0; i < iplimage.length; i++) {
long t = 1000 * (System.currentTimeMillis() - startTime);
if (t < recorder.getTimestamp()) {
t = recorder.getTimestamp() + 1000;
}
recorder.setTimestamp(t);
recorder.record(iplimage[i]);
}
} catch (Exception e) {
e.printStackTrace();
}

- 3,369
- 12
- 36
- 47

- 189
- 1
- 5
An object used to create frame-by-frame animations, defined by a series of Drawable objects, which can be used as a View object's background.
The simplest way to create a frame-by-frame animation is to define the animation in an XML file, placed in the res/drawable/ folder, and set it as the background to a View object. Then, call start() to run the animation.
An AnimationDrawable defined in XML consists of a single element, and a series of nested tags. Each item defines a frame of the animation. See the example below.
spin_animation.xml file in res/drawable/ folder:
<!-- Animation frames are wheel0.png -- wheel5.png files inside the
res/drawable/ folder -->
<animation-list android:id="@+id/selected" android:oneshot="false">
<item android:drawable="@drawable/wheel0" android:duration="50" />
<item android:drawable="@drawable/wheel1" android:duration="50" />
<item android:drawable="@drawable/wheel2" android:duration="50" />
<item android:drawable="@drawable/wheel3" android:duration="50" />
<item android:drawable="@drawable/wheel4" android:duration="50" />
<item android:drawable="@drawable/wheel5" android:duration="50" />
</animation-list>
Here is the code to load and play this animation.
// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
img.setBackgroundResource(R.drawable.spin_animation);
// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// Start the animation (looped playback by default).
frameAnimation.start();

- 3,773
- 7
- 35
- 47
-
Thanks @Aakash but how are you planning to save it as a video file ? – Shishir Shetty Jan 25 '13 at 12:54