4

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. ?

Shishir Shetty
  • 2,021
  • 3
  • 20
  • 35

4 Answers4

2

You need a library for creating these. There are some post here about that:

Java Package to create video

Video Creation with Xuggler

Tutorial :

Tutorial To create Video from Xuggler

Community
  • 1
  • 1
Vikalp Patel
  • 10,669
  • 6
  • 61
  • 96
0

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.

Community
  • 1
  • 1
AggelosK
  • 4,313
  • 2
  • 32
  • 37
0

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();
}
Maximilian Ast
  • 3,369
  • 12
  • 36
  • 47
Manish Godhani
  • 189
  • 1
  • 5
-2

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();
Aakash Anuj
  • 3,773
  • 7
  • 35
  • 47