vlc android的編譯及截圖,錄製視訊等功能
阿新 • • 發佈:2019-01-10
編譯的環境是ubuntu 12.04,要安裝好java,配置好環境變數,按照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
2014/03/26日更新開始
在ubuntu下編譯vlc https://wiki.videolan.org/AndroidCompile/ 安裝工具 sudo apt-get install ant autoconf automake autopoint cmake gawk gcc g++ libtool m4 patch pkg-config ragel subversion yasm git切換vlc android 版本到 0.1.x-bugfix cd android git branch -r git checkout 0.1.x-bugfix
2014/03/26日更新結束
為了在android vlc上增加截圖和儲存視訊的功能
截圖:
要對android/configure.sh進行修改 刪掉其中的-disable-sout
另外儲存圖片為png格式,需要讓ffmpeg增加-enable-encoder=png的編碼器(在android/vlc/contrib/src/ffmpeg/rules.mak中修改)
2014/03/26日更新開始
FFMPEGCONF += --disable-encoders --disable-muxers
->FFMPEGCONF += --disable-encoders --enable-encoder=png2014/03/26日更新結束
在libvlcjni.c中增加函式:
- jboolean Java_org_videolan_libvlc_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 */
- constchar* 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函式的介面
- privatenativeboolean takeSnapShot( int num, String file, int width, int height);
- publicboolean takeSnapShot(String file, int width, int height) {
- return takeSnapShot(0, file, width, height);
- }
編譯後就可以使用。呼叫LibVlc.java中的takeSnapShot就可以實現截圖了。
錄製視訊:
2014/03/26日更新開始
-
- 把patch檔案放到/android/vlc中 使用命令patch -p1 < xxxx.patch 查出其中的失敗的地方 手動修改
- 修改vlc-android/jni/libvlcjni.c 在檔案末尾新增
-
- jboolean Java_org_videolan_libvlc_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 */
- constchar* 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;
- }
- jboolean Java_org_videolan_libvlc_LibVLC_videoRecordStart(JNIEnv *env, jobject thiz,jstring path)
- {
- jboolean isCopy;
- libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
- /* Get C string */
- constchar* 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_libvlc_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;
- }
- jboolean Java_org_videolan_libvlc_LibVLC_videoIsRecording(JNIEnv *env, jobject thiz)
- {
- jboolean isCopy;
- libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
- if (mp)
- if(libvlc_media_player_is_recording(mp))
- return JNI_TRUE;
- return JNI_FALSE;
- }
- jboolean Java_org_videolan_libvlc_LibVLC_videoIsRecordable(JNIEnv *env, jobject thiz)
- {
- jboolean isCopy;
- libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
- if (mp)
- if(libvlc_media_player_is_recordable(mp))
- return JNI_TRUE;
- return JNI_FALSE;
- }
- jint Java_org_videolan_libvlc_LibVLC_getState(JNIEnv *env, jobject thiz)
- {
- libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
- if (mp){
- libvlc_state_t state=libvlc_media_player_get_state(mp);
- return (jint)state;
- }
- else
- return -1;
- }
2014/03/26日更新結束
送佛送到西 原始碼下載地址http://pan.baidu.com/s/17Y4dO