2013-01-25 84 views
4

我有一组图像与我,我希望通过循环运行它们,并将其保存为SD卡中的视频文件。有没有我可以使用的Android的任何默认工具。 ?任何可以满足我的要求的图书馆。 ?将图像转换为Android中的单个视频文件

+0

http://stackoverflow.com/questions/13643046/how-to-convert-images-into-video-in-android-using-javacv –

+0

http://stackoverflow.com/questions/13643046/how-to-convert-images-into-video-in-android-using -javacv 访问上面的链接... –

回答

0

有在支持此功能Android库没有内置。 This SO post建议使用通过Java端口或使用Android NDK以C/C++编写的ffmpeg

-1

用于创建逐帧动画的对象,由一系列Drawable对象定义,可用作View对象的背景。

创建逐帧动画的最简单方法是在XML文件中定义动画,放置在res/drawable /文件夹中,并将其设置为View对象的背景。然后,调用start()来运行动画。

XML中定义的AnimationDrawable由单个元素和一系列嵌套标签组成。每个项目定义了动画的一个框架。看下面的例子。在res /绘制/文件夹

spin_animation.xml文件:

<!-- 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> 

这里是加载和播放这个动画的代码。

// 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(); 
+0

谢谢@Aakash,但你打算如何保存它作为一个视频文件? –

+0

该代码不能在我的电脑上工作 – deepak825

0

使用的Java javacpp.jarjavacv.jar在你的Android项目创建一系列图像视频

下面的代码用于创建视频

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(); 
} 
相关问题