【发布时间】:2016-07-01 10:48:25
【问题描述】:
对于一个项目,我必须逐帧对视频进行一些操作(例如在视频上绘制元素)。是否有方法可以让我在 Android 上逐帧执行操作?
【问题讨论】:
标签: android video frame android-videoview
对于一个项目,我必须逐帧对视频进行一些操作(例如在视频上绘制元素)。是否有方法可以让我在 Android 上逐帧执行操作?
【问题讨论】:
标签: android video frame android-videoview
如果您有帧,则可以使用 Android 的逐帧动画技术。
<!-- Animation frames are wheel0.png through 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>
使用图像视图播放这些帧。
ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image); img.setBackgroundResource(R.drawable.spin_animation); AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// 开始动画(默认循环播放)。 frameAnimation.start();
参考。
https://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html
【讨论】: