Android Live Streaming courtesy of JavaCV and FFMPEG

For the last little or should I say, long while I have been working on wrangling a solution for live streaming from Android that is both decent quality and extensible. For those of you interested, the litter in my GitHub account documents various previous attempts.

As far as I can tell, most folks that are streaming live video from Android are relying upon the video captured by the MediaRecorder and underlying classes and doing a bit of trickery with the file either while it sent to the server or on the server for distribution. This is fine but it doesn’t give hooks into the actual video frames before they are encoded and sent over the network.

Recently, I came across Samuel Audet’s amazing open source JavaCV project. In that project Samuel is wrapping FFMPEG’s underlying libraries (avcodec, avformat, and so on) using his equally amazing JavaCPP project to expose their functionality to any Java application.

Finally, after a few weeks of experimentation and little (actually a LOT) of help from Samuel himself, I have something working!

Running the live streaming app on a Galaxy Camera
Running the live streaming app on a Galaxy Camera

App and resulting stream on desktop via Wowza Media Server and Flash

There is a quick example of writing a file up on the JavaCV site which provides the foundation:

I have the beginnings of a full blown project (which needs some updating based on the above example) up on GitHub:

68 thoughts on “Android Live Streaming courtesy of JavaCV and FFMPEG”

  1. Hi,
    This seems to be an interesting project. Can you walk me through the testing steps? Thanks in advance.

  2. It really is an amazing project.

    Thank you very much.

    When you try to use the VideoInputFrameGrabber that is in your javacv library, the problem occurs.

    Is it possible that I am sent a JNI file if there is no rude?

    Since that has been modified to FFMpegRecorder, javacv you will not be able to use that are existing open.

    Once again, thank you wonderful project.

  3. When change format video to “mp4″
    The problem is ” Fatal signal 8 (SIGFPE) at 0x00002fc5 (code=-6), thread 12258 (Thread-334)”
    can you help me ?

  4. Hi, do you have a newer version of your example that uses JavaCV 0.11? I tried the RecordActivity but could not get it to work. Is there anything else I should do except for changing the ffmpeg_url to a RTMP url?

  5. Hi Chris,

    Sorry, I haven’t tried this with more recent versions of JavaCV. If you get it to work, would be great to hear.


  6. This contribution has been of great help to the development of my degree ttabajo telepresence.

  7. i am not able to import this project on eclipse , it is showing a red exclamation mark on top of project, it looks like i am missing some library. Any help will be appreciated

  8. Hi i’m using this project and try to understand things..

    Streaming is working perfectly but not save in wowza server, only save audio file.
    if i try with other sdk like libstreaming then that stream save in server.
    So means there is no issue from server side..

    i have tried to make things more accurate but still not able to save the full video in server.

    here is my question in stackoverflow

    Somebody have idea please give me bit knowledge where i’m wrong

  9. Indeed, this is all very useful information, but from what I gather, there are multiple issues and bugs with the codes you offered. If you are looking for an easy way out, you could always try RTMP protocol provided by Streamaxia ( Moreover, they offer WebRTC tools and OpenSDK live video streaming library for Android!
    P.S. It works perfectly with Wowza.
    Useful links:
    Happy coding!

  10. any one please help me
    i try to develop the android video live stream app
    I have already searched for many apis that might provide support for Android app development

Leave a Reply

Your email address will not be published. Required fields are marked *