在前面的文章中我们用ffmpeg在windows上实现了多种功能,下面系列的文章我们将移植到Android系统上实现。
我们将使用最新版:
最新版ffmpeg ffmpeg3.3
新版Android studio Android studio2.3
新版JNI编译方式 CMake
对于Android开发者或许对C/C++/JNI知识不够了解。
可以先看这里:
C语言小结 :http://blog.csdn.net/king1425/article/details/70256764
C++小结(一) : http://blog.csdn.net/king1425/article/details/70260091
JNI高阶知识总结 : http://blog.csdn.net/king1425/article/details/71405131
下面我们开始实现今天的功能:
1.编译Android版ffmpeg并移植到Android studio中
看这里:
windows下编译最新版ffmpeg3.3-android,并通过CMake方式移植到Android studio2.3中
http://blog.csdn.net/king1425/article/details/70338674
2.复制一份第一步移植成功的的代码命名为:ffmpegandroiddecoder
3.删减部分代码验证无误,然后编写布局代码逻辑代码
点击codec按钮出现如上图列表界面则无误
下面是相关代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btn_codec"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="Codec"
android:textAllCaps="false" />
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:text="ws2.mp4"
android:id="@+id/editText1" />
<EditText
android:layout_width="match_parent"
android:layout_height=