Android VLC 录像跟截图功能

Linux环境,按照http://wiki.videolan.org/AndroidCompile配置好,就可以编译了。

[plain]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. export JAVA_HOME=/home/sunlit/jdk1.6.0_38/  
  2. export PATH=$JAVA_HOME/bin:$PATH  
  3. export classPath=/home/sunlit/jdk1.6.0_38/  
  4. export ANDROID_SDK=/home/sunlit/sdk  
  5. export ANDROID_NDK=/home/sunlit/android-ndk-r8c  
  6. export PATH=$PATH:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools  
  7. 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中增加函数:

[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. jboolean Java_org_videolan_vlc_LibVLC_takeSnapShot(JNIEnv *env, jobject thiz,jint number, jstring path, jint width,jint height)  
  2. {  
  3.     jboolean isCopy;  
  4.    libvlc_media_player_t *mp = getMediaPlayer(env, thiz);  
  5.      /* Get C string */  
  6.    const char* psz_path = (*env)->GetStringUTFChars(env, path, &isCopy);  
  7.   
  8.    if (mp)  
  9.         if(libvlc_video_take_snapshot(mp, (int)number,psz_path , (int)width,(int)height)==0)  
  10.             return JNI_TRUE;  
  11.    return JNI_FALSE;  
  12.   
  13. }  

在LibVlc.java中增加native函数的接口

[java]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. private native boolean takeSnapShot( int num, String file, int width, int height);  
和调用方法

[java]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. public boolean takeSnapShot(String file, int width, int height) {  
  2.     return takeSnapShot(0, file, width, height);  
  3. }  

上述代码都是在android目录下的代码里改的。

执行 sh compile.sh 重新编译整个项目

编译后就可以使用。调用LibVlc.java中的takeSnapShot就可以实现截图了。

录制视频:

增加录像功能需要按照https://patches.videolan.org/patch/606/ patch 部分更改vlc源码


更改完源码后, 需要在libvlcjni.c文件里增加调用录像的函数

[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
jboolean Java_org_videolan_vlc_LibVLC_videoRecordStart(JNIEnv *env, jobject thiz,jstring path)
{
    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

[java]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. public native boolean videoRecordStart(String path);


    public native boolean videoRecordStop();
执行 sh compile.sh 重新编译整个项目


调用LibVlc.java中的videoRecordStar开始录像

感谢xxx大哥的指导
本文参考http://blog.csdn.net/xinchen200/article/details/17451977

有任何问题请留言

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值