Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中将图像集转换为单个视频文件_Android_Image_Video - Fatal编程技术网

在android中将图像集转换为单个视频文件

在android中将图像集转换为单个视频文件,android,image,video,Android,Image,Video,我随身携带一组图像,我希望通过循环运行它们,并将其保存为SD卡中的视频文件。安卓系统中有我可以使用的默认工具吗?任何能满足我要求的图书馆 您需要一个库来创建这些。这里有一些关于这方面的帖子: 教程: 没有内置的Android库支持此功能。建议通过Java端口使用C/C++编写的ffmpeg,或使用Android NDK一个用于创建逐帧动画的对象,该对象由一系列可绘制对象定义,可以用作视图对象的背景 创建逐帧动画的最简单方法是在放置在res/drawable/文件夹中的XML文件中定义动画,并

我随身携带一组图像,我希望通过循环运行它们,并将其保存为SD卡中的视频文件。安卓系统中有我可以使用的默认工具吗?任何能满足我要求的图书馆

您需要一个库来创建这些。这里有一些关于这方面的帖子:

教程:


没有内置的
Android
库支持此功能。建议通过Java端口使用C/C++编写的
ffmpeg
,或使用
Android NDK
一个用于创建逐帧动画的对象,该对象由一系列可绘制对象定义,可以用作视图对象的背景

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

 // 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();
XML中定义的AnimationDrawable由单个元素和一系列嵌套标记组成。每个项目定义动画的一个帧。请参见下面的示例

res/drawable/文件夹中的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>

在android项目中使用Java
javacpp.jar
javacv.jar
创建一系列视频图像

下面的代码用于创建视频

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();
}
recorder=新的FFmpegFrameRecorder(“Videofilename”,480480);
试一试{
录像机。设置视频编解码器(13);
记录器。设置帧速率(0.4d);
recorder.setPixelFormat(0);
录像机。设置视频质量(1.0d);
记录器。设置视频比特率(4000);
startTime=System.currentTimeMillis();
recorder.start();
int time=Integer.parseInt(参数[0]);
resp=“睡眠时间+时间+毫秒”;
对于(int i=0;i
访问上述链接…@Shishir Shetty。。。你找到解决办法了吗?@Androiddev我最后用了。请注意,这就像5年前一样。谢谢@Aakash,但是你打算如何将它保存为视频文件?jar文件在哪里?没有链接。