Android - streaming camera as RTMP stream

I want to capture the camera stream from an Android device and transfer it to a server with RTMP (the server is out of my control). I still do not understand how to create a data stream from the camera itself, but this concerns a later problem.

There are two problems at the moment: I want to support API 9+, and RTMP is not supported on the Android platform.

I looked and found this SO message Convert video input stream to RTMP and https://github.com/yixia/VitamioBundle . The first proposed a library that has virtually no documentation. The latter probably supports it (?), But this requires API 14 +.

Are there any decent examples or libraries that support RTMP streams from an Android device? I also read something about converting RTSP or FFMPEG, if this is a viable way, I think that will also be enough.

Change 1:

I found this library (it has many similarities to the one mentioned above) and tried to work. I imported it into Android Studio and wrote some code, but it seems to crash inside with the java.lang.NoClassDefFoundError RTSP Codec Factory error. So apparently this doesn't work too well on Android.

In addition, I have encountered Adobe AIR several times. I do not want to code in Action Script 3 (AS3), as this library will be just a (small) part of its own application. If Adobe Air has a library that I don’t know about, then I would love to integrate it if possible.

+8
android video-streaming rtmp
source share
3 answers

In the accepted answer to the question you linked , someone suggests using JavaCV.

It requires API 8 or later and has the FFmpegFrameRecorder class.

Link to github:

https://github.com/bytedeco/javacv

They even have a full flv capture sample (it's pretty big, so I won’t insert it here): https://github.com/bytedeco/javacv/blob/master/samples/RecordActivity.java

In your case, you probably have to replace:

 private String ffmpeg_link = "/mnt/sdcard/stream.flv"; 

from

 private String ffmpeg_link = "rtmp://<server>:<port>/stream"; 
+15
source share

You should take a look at spydroid ; he does exactly what you are looking for. Their site can be found here: https://code.google.com/p/spydroid-ipcamera/

They provide a library that you can use, as well as an explanation of the various streaming options and some code examples. The specified information can be found here: https://github.com/fyhertz/libstreaming

+2
source share

If you can publish to your Android device using a protocol supported by ffmpeg (see the list of supported protocols ), you can use the following command to transfer video to your server:

 ffmpeg -re -i <input link> -vcodec h264 -ar 44100 -f flv "rtmp://<host>/<publication>" 
+1
source share

All Articles