Menu

using ffmpeg

Help
riv111
2013-01-25
2013-09-03
  • riv111

    riv111 - 2013-01-25

    I downloaded the source but there is no way to open the project using the ADT tools.

    I am just wanting to integrate ffmpeg into an already existing Android app. Can I import some of the .java files files into my project to get it to work?

    Any suggestions would be great.

    Thanks

     
  • William Seemann

    William Seemann - 2013-01-25

    Hello, I'm not quite understanding. Did you download the entire trunk? Are you are saying you can't set that up as a project in Eclipse using the ADT plugin? Specifically what are you trying to do with FFmpeg? I might be able to provide more assistance if you can send me more information.

     
  • riv111

    riv111 - 2013-01-25

    William:

    Thank you for the quick response.

    I downloaded the project using the svn command provided in the 'Code' tab. That created a directory with all of the source code files and scripts etc.. I tried to open that in Eclipse but it could not find the project to open. It said there were no project files available. I tried a few other things but it would not open. Am I missing something here?

    Also, what I was saying was that I already have an existing media player app that I have created. I would like the ability to integrate the ffmpeg library into it so I could stream some mms:// streams as well. This was my initial goal and so I downloaded your code to see if i could replicate the functinality of ffmpeg in my project. Unfortunately I couldn't open the project. If there is something I could do to integrate ffmpeg into an existing project that would be great.

    Thanks again for the help.

     
  • William Seemann

    William Seemann - 2013-01-26

    The code is in the "trunk" folder:

    http://svn.code.sf.net/p/servestream/code/trunk/

    You should be able to create a new "Android Project from Existing Code" in Eclipse and use the root "trunk" folder as the source code path. If you do go that route you will also need to download ActionBarSherlock and add that to your Eclipse workspace also. If you use ant (which comes with the SDK) you can also build the project on Linux by following the directions in the README file found in the root "trunk" folder.

    If you would like to implement the FFmpeg based player into your application you need to download:

    Java:
    http://svn.code.sf.net/p/servestream/code/trunk/src/net/sourceforge/servestream/player/FFmpegPlayer.java

    C (Everything in this directory minus the "metadata" folder):
    http://svn.code.sf.net/p/servestream/code/trunk/jni/

    You will need to build FFmpeg to match the desired codecs and your application package. The scripts are located here:

    http://svn.code.sf.net/p/servestream/code/trunk/scripts/

    FFmpegPlayer.java uses the same interface as the Android MediaPlayer so you can play a MMS stream with the following code:

    FFmpegPlayer mediaPlayer = new FFmpegPlayer;
    mediaPlayer.setOnPreparedListener(onPreparedListener);
    mediaPlayer.setDataSource("mmsh://<some url="">");
    mediaPlayer.prepareAsync();

    ...

    private FFmpegPlayer.OnPreparedListener onPreparedListener = new FFmpegPlayer.OnPreparedListener() {
    public void onPrepared(FFmpegPlayer mp) {
    mp.start();
    }
    };

    Let me know if you have any additional questions.

     
  • riv111

    riv111 - 2013-01-26

    William:

    Thanks again. I got all the code and was able to create a new project using the existing code.

    I really just wanted to build the ffmpeg library for use in my existing application but I could not understand exactly how to do that.

    I went through the instructions but being so new to this it was a little unclear. I found the FFMPEG for Android project and downloaded that as well but I did not have the NDK installed.

    I have an existing application that has: android:minSdkVersion="7".
    I just wanted the ffmpeg library to integrate into this application so I could play some mms:// streams.

    Does the ffmpeg library have to be built with the specific application that I want to integrate it with, or can I build it once and use it in multiple projects?

    It doesn't seem like there is a list of universal commands that can be used to built it. I thought that process would be simple but it is not that cut and dry.

    Any other ideas?

    Thanks

     
  • William Seemann

    William Seemann - 2013-01-26

    Compiling FFmpeg is somewhat complicated so it might be easier/quicker to explain over chat. I use gchat (wseemann @ gmail.com) If you want to message me I can walk you through the process.

     
  • xrlyz

    xrlyz - 2013-08-29

    I'm having trouble building FFmpeg library.

    Logcat says:

    E/AndroidRuntime(29767): FATAL EXCEPTION: main
    E/AndroidRuntime(29767): java.lang.ExceptionInInitializerError
    E/AndroidRuntime(29767): at com.test.radio.TestActivity.getFFmpegPlayer(TestActivity.java:177)
    E/AndroidRuntime(29767): at com.test.radio.TestActivity.play(TestActivity.java:73)
    E/AndroidRuntime(29767): at com.test.radio.TestActivity.access$3(TestActivity.java:69)
    E/AndroidRuntime(29767): at com.test.radio.TestActivity$4.onClick(TestActivity.java:42)
    E/AndroidRuntime(29767): at android.view.View.performClick(View.java:2485)
    E/AndroidRuntime(29767): at android.view.View$PerformClick.run(View.java:9080)
    E/AndroidRuntime(29767): at android.os.Handler.handleCallback(Handler.java:587)
    E/AndroidRuntime(29767): at android.os.Handler.dispatchMessage(Handler.java:92)
    E/AndroidRuntime(29767): at android.os.Looper.loop(Looper.java:130)
    E/AndroidRuntime(29767): at android.app.ActivityThread.main(ActivityThread.java:3683)
    E/AndroidRuntime(29767): at java.lang.reflect.Method.invokeNative(Native Method)
    E/AndroidRuntime(29767): at java.lang.reflect.Method.invoke(Method.java:507)
    E/AndroidRuntime(29767): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    E/AndroidRuntime(29767): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    E/AndroidRuntime(29767): at dalvik.system.NativeStart.main(Native Method)
    E/AndroidRuntime(29767): Caused by: java.lang.UnsatisfiedLinkError: native_init
    E/AndroidRuntime(29767): at com.test.radio.media.FFmpegPlayer.native_init(Native Method)
    E/AndroidRuntime(29767): at com.test.radio.media.FFmpegPlayer.<clinit>(FFmpegPlayer.java:560)
    E/AndroidRuntime(29767): ... 15 more

     
  • William Seemann

    William Seemann - 2013-08-30

    I see that added FFmpegPlayer.java to your own project by the package name shown in the error (com.test.radio.media). When you compiled FFmpeg did you change the hardcoded package in the scripts from "net.source forge.servestream" to "com.test.radio"? You also need to modify the package name (kClassPathName) in jni/player/ffmpeg_player.c?

     
  • xrlyz

    xrlyz - 2013-09-02

    How can I re-compile the library again? Can you give a detailed instruction to compile FFmpeg from the start?
    Sorry I'm not yet familiar using NDK.


    I run ndk-build clean and ndk-build but still the error appears.

     

    Last edit: xrlyz 2013-09-02
  • William Seemann

    William Seemann - 2013-09-03

    Sorry, I'm not going to post detailed instructions, I simply don't have time. It's also worth noting that you also need to change the JNI function headers in ffmpeg_player.c to match your package name in addition to changing the kClassPathName variable.

    If you want to perform a clean FFmpeg build delete the binaries located in "jni/ffmpeg/ffmpeg" and run "ant build-ffmpeg" from the project root. When the FFmpeg build completes can then run "ndk-build clean" and "ndk-build".

     

Log in to post a comment.