VLC Android compilation, screenshot taking, recording video, and other functions

Source: Internet
Author: User

The compiled environment is Ubuntu 12.04. To install Java and configure environment variables, configure them according to http://wiki.videolan.org/androidcompile.

export JAVA_HOME=/home/sunlit/jdk1.6.0_38/export PATH=$JAVA_HOME/bin:$PATHexport classPath=/home/sunlit/jdk1.6.0_38/export ANDROID_SDK=/home/sunlit/sdkexport ANDROID_NDK=/home/sunlit/android-ndk-r8cexport PATH=$PATH:$ANDROID_SDK/platform-tools:$ANDROID_SDK/toolsexport ANDROID_ABI=armeabi-v7a

To add and save videos on Android VLC

:

Modify Android/configure. Sh to delete the-Disable-sout

In addition, to save the image as PNG, you need to add the-enable-Encoder = PNG encoder to FFMPEG (in Android/VLC/contrib/src/FFMPEG/rules. Mak)

Add the function in 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;}

Add the native function interface to libvlc. java.

    private native boolean takeSnapShot( int num, String file, int width, int height);

And call Methods

    public boolean takeSnapShot(String file, int width, int height) {        return takeSnapShot(0, file, width, height);    }

It can be used after compilation. Call the takesnapshot in libvlc. java.

Video Recording:

(This Part references the Web Article http://blog.csdn.net/sooth2008/article/details/6787459)

1. add the declarative function: Find the include \ VLC \ libvlc_media_player.h file and search for the libvlc_video_take_snapshot function. The reason why I mentioned this function is that the video recording function is very similar to this function, if you want to add other functions, you can also refer to the existing functions of VLC. find libvlc_video_take_snapshot and add the name

VLC_PUBLIC_API int libvlc_video_toggle_record( libvlc_media_player_t *p_mi,const char *psz_filepath, const char *psz_fileame );


The video function of my video function is like this: the video starts to be recorded once, and stops recording once again. So the name is toggle. Then the declaration function is added.

2. Add the implementation function: Find Android/VLC/lib/video. C, and then add the function implementation as follows:

int libvlc_video_toggle_record( libvlc_media_player_t *p_mi,                                const char *psz_filepath, const char *psz_filename ){input_thread_t *p_input = libvlc_get_input_thread( p_mi );if(p_input == NULL)return -1;var_SetString( p_input, "input-record-path", psz_filepath );var_SetString( p_input, "sout-record-dst-prefix", psz_filename );var_ToggleBool( p_input, "record");vlc_object_release(p_input);return 0;}

3. Add the libvlc_video_toggle_record declaration to the LIB/libvlc. sym file.

Modify libvlcjni. C and libvlc. Java to call

However, the function implementation of video recording is a bit problematic. I am debugging it.

(Ztesoft)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.