37

I want to stream video recording from my android phone to network media server.

The first problem is that when setting MediaRecorder output to socket, the stream is missing some mdat size headers. This can be fixed by preprocessing that stream locally and adding missing data to stream in order to produce valid output stream.

The question is how to proceed from there.

How can I go about output that stream as an RTMP stream?

Marko
  • 30,263
  • 18
  • 74
  • 108
  • I assume you've looked at current solutions like [this one](http://www.aftek.com/afteklab/aftek-RTMP-library.shtml) and determined that they didn't meet your needs? The common alternative, of course, is to use [RTSP](https://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol), which is natively supported by Android. It seems you're already doing so (stating that the packet structure needs to be updated for, for example, `mdat` size headers). Red5 and Wowza appear to not have full _RTSP_ support, but [this](http://erlyvideo.org/) may work if you go that route. – MrGomez Apr 20 '12 at 19:05
  • @MrGomez if you found solution how to stream from android to server using RTMP - please provide it. thanks – jimpanzer Apr 08 '13 at 09:28
  • 1
    I think [PLDroidCameraStreaming](https://github.com/pili-engineering/PLDroidCameraStreaming) is a good choice. – Jerikc XIONG Mar 23 '16 at 09:45

2 Answers2

51

First, let's unwind your question. As you've surmised, RTMP isn't currently supported by Android. You can use a few side libraries to add support, but these may not be full implementations or have other undesirable side effects and bugs that cause them to fail to meet your needs.

The common alternative in this case is to use RTSP. It provides a comparable session format that has its own RFC, and its packet structure when combined with RTP is very similar (sans some details) to your desired protocol. You could perform the necessary fixups here to transmute RTP/RTSP into RTMP, but as mentioned, such effort is currently outside the development scope of your application.

So, let's assume you would like to use RTMP (invalidating this thread) and that the above-linked library does not meet your needs.

You could, for example, follow this tutorial for recording and playback using Livu, Wowza, and Adobe Flash Player, talking with the Livu developer(s) about licensing their client. Or, you could use this client library and its full Android recorder example to build your client.

To summarize:

RTSP

RTMP

Best of luck with your application. I admit that I have a less than comprehensive understanding of all of these libraries, but these appear to be the standard solutions in this space at the time of this writing.

Edit:

According to the OP, walking the RTMP library set:

In short: more work is needed. Other answers, and improvements upon these examples, are what's needed here.

Community
  • 1
  • 1
MrGomez
  • 23,788
  • 45
  • 72
  • 1
    AFAIR, RSSP is not an option since it require device to serve video. I would prefer if device could publish video to server. – Marko Apr 23 '12 at 21:00
  • @MarkoKocić From what I understand and what I've read, publication functionality from Android is plausible with this protocol. But, let's ignore that for a moment. Can you expand on why this set of RTMP solutions doesn't work for you? Accepting or refuting them will greatly help me and other answerers better understand your needs. – MrGomez Apr 23 '12 at 21:40
  • @MarkoKocić Understood. I'll perform more research when I have a chance to see if I can make these better meet your needs. In the future, please spool your response out as a comment or a question update; [updating an answer directly](http://stackoverflow.com/posts/10252369/revisions) with additional content is, excepting community wiki posts, not a desirable edit according to SO's style guidelines. :) – MrGomez Apr 23 '12 at 22:08
  • @MarkoKocić I'm not especially proud about failing to completely answer this question before the half-bounty fired (to be fair, I was horrifically busy last week). I'm still looking into better solutions, but if someone else nabs this with a succinct and correct answer, I most certainly won't complain! – MrGomez Apr 30 '12 at 21:32
  • can you say something about how to get stream video from rtmp server [here is my post](http://stackoverflow.com/questions/20141244/how-to-get-video-stream-from-rtmp-server-to-android) – NickUnuchek Nov 29 '13 at 09:32
  • Try OS Broadcaster for Android (also one for iOS), it is an excellent RTMP video camera streamer. – Andrew Aug 26 '14 at 19:44
1

If you are using a web-browser on Android device, you can use WebRTC for video capturing and server-side recording, i.e with Web Call Server 4

Thus the full path would be:

Android Chrome [WebRTC] > WCS4 > recording

So you don't need RTMP protocol here.

If you are using a standalone RTMP app, you can use any RTMP server for video recording. As i know Wowza supports H.264+Speex recording.

eeKat88
  • 106
  • 1
  • 7