Linux环境,按照http://wiki.videolan.org/AndroidCompile配置好,就可以编译了。
- export JAVA_HOME=/home/sunlit/jdk1.6.0_38/
- export PATH=$JAVA_HOME/bin:$PATH
- export classPath=/home/sunlit/jdk1.6.0_38/
- export ANDROID_SDK=/home/sunlit/sdk
- export ANDROID_NDK=/home/sunlit/android-ndk-r8c
- export PATH=$PATH:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools
- export ANDROID_ABI=armeabi-v7a
为了在android vlc上增加截图和保存视频的功能
截图:
要对android/configure.sh进行修改 删掉其中的-disable-sout
另外保存图片为png格式,需要让ffmpeg增加-enable-encoder=png的编码器(在android/vlc/contrib/src/ffmpeg/rules.mak中修改)
注意:更改完rules.mask, 需要touch android/vlc/contrib/android/ffmpeg, 这样确保ffmpeg会被重新编译。
在libvlcjni.c中增加函数:
- jboolean Java_org_videolan_vlc_LibVLC_takeSnapShot(JNIEnv *env, jobject thiz,jint number, jstring path, jint width,jint height)
- {
- jboolean isCopy;
- libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
- /* Get C string */
- const char* psz_path = (*env)->GetStringUTFChars(env, path, &isCopy);
- if (mp)
- if(libvlc_video_take_snapshot(mp, (int)number,psz_path , (int)width,(int)height)==0)
- return JNI_TRUE;
- return JNI_FALSE;
- }
在LibVlc.java中增加native函数的接口
- private native boolean takeSnapShot( int num, String file, int width, int height);
- public boolean takeSnapShot(String file, int width, int height) {
- return takeSnapShot(0, file, width, height);
- }
上述代码都是在android目录下的代码里改的。
执行 sh compile.sh 重新编译整个项目
编译后就可以使用。调用LibVlc.java中的takeSnapShot就可以实现截图了。
录制视频:
增加录像功能需要按照https://patches.videolan.org/patch/606/ patch 部分更改vlc源码
更改完源码后, 需要在libvlcjni.c文件里增加调用录像的函数
{
jboolean isCopy;
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
/* Get C string */
const char* psz_path = (*env)->GetStringUTFChars(env, path, &isCopy);
//const char* psz_filename=(*env)->GetStringUTFChars(env, filename, &isCopy);
if (mp)
if(libvlc_media_player_record_start(mp,psz_path)==0)
return JNI_TRUE;
return JNI_FALSE;
}
jboolean Java_org_videolan_vlc_LibVLC_videoRecordStop(JNIEnv *env, jobject thiz)
{
jboolean isCopy;
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
/* Get C string */
if (mp)
if(libvlc_media_player_record_stop(mp)==0)
return JNI_TRUE;
return JNI_FALSE;
}
2.然后在LibVLC.java里面增加native method
- public native boolean videoRecordStart(String path);
public native boolean videoRecordStop();
调用LibVlc.java中的videoRecordStar开始录像
感谢xxx大哥的指导
本文参考http://blog.csdn.net/xinchen200/article/details/17451977
有任何问题请留言