6

My new surveillance camera just arrived, so I'm trying to write an app to live stream the video from it.

Since it came with basically no documentation, I installed the 'onvifer' android app which allows you to browse the camera's capabilities. This app works fine - gets the video and allows PTZ controls, etc. It reports the streaming url as:

 rtsp://192.1.0.193:554/mpeg4

I tested the stream in the VLC windows client, and it's able to stream video from that URL as well. This makes me comfortable that the network is working OK.

The camera states the feed will be 1920x1080; VLC confirms this.

The basic code in my activity:

VideoView videoView = (VideoView)this.findViewById(R.id.VideoView);
videoView.setVideoURI(Uri.parse("rtsp://192.1.0.193:554/mpeg4"));
videoView.requestFocus();
videoView.start();

I've also given the app INTERNET permissions in AndroidManifest.xml, disabled authentication on the camera, and am running on a real device (not the emulator).

When I run the app, LogCat shows this immediately:

setDataSource IOException happend :
java.io.FileNotFoundException: No content provider: rtsp://192.1.0.193:554/mpeg4
at android.content.ContentResolver.openTypedAssetFileDescriptor (ContentResolver.java).

About 15 seconds later, the app shows a "Can't play this video" modal dialog box and this is added to LogCat:

MediaPlayer      error (100, 0)
AudioSystem      AudioFlinger server died!
MediaPlayer      error (100, 0)
VideoView        Error: 100,0

I've googled everything I can think of, but haven't found anything useful.

Any thoughts?

Mycoola
  • 1,135
  • 1
  • 8
  • 29
Alain Collins
  • 16,268
  • 2
  • 32
  • 55
  • since it is a mediaplayer, I miss a preprare or prepareasync somewhere before start(). I always needed it. – sschrass Aug 09 '14 at 06:13
  • @SatelliteSD, thanks for the reply. I'm using the VideoView wrapper for MediaPlayer, and, from what I can tell, it takes care of the prepare(). http://stackoverflow.com/questions/18598675/calling-mediaplayer-prepareasync-from-videoview – Alain Collins Aug 09 '14 at 16:29
  • seen this answer? http://stackoverflow.com/questions/13291632/unable-to-play-rtsp-using-videoview-in-android And here an explanaiton pf the problem and how VLC overcomes it. http://fabiensanglard.net/mobile_progressive_playback/index.php – sschrass Aug 09 '14 at 17:35
  • Thanks again, @SatelliteSD. I had seen mention of that issue, but it didn't make sense without your second link. I'll have to see if I can figure out how to diagnose/code the stated workaround myself. I'll post back when I know. – Alain Collins Aug 11 '14 at 04:52
  • @SatelliteSD, this post states that the MOOV header is an issue when streaming *files*, not live streaming (which is what I'm doing). Thoughts? "In the case of RTSP streams, there is an SDP transaction with the server that provides the metadata required for the player to start playback." https://www.mail-archive.com/android-framework@googlegroups.com/msg02086.html – Alain Collins Aug 12 '14 at 20:13
  • the only thing I can think of momentarily is, that you may not provide audio? So AudioSystem *may* desperatly tries to find audio on your stream. Totaly guessed. – sschrass Aug 13 '14 at 07:33
  • The camera has audio capabilities, which I haven't touched yet. – Alain Collins Aug 13 '14 at 22:08
  • To rule out HD problems, I tried the second stream (704x576), which gives the same error. – Alain Collins Aug 13 '14 at 22:10
  • I got the same results when using my phone. Both are 4.4.2, though different manufacturers. – Alain Collins Aug 14 '14 at 00:11
  • Did you solve this problem? – Massimo Jul 19 '16 at 12:59
  • @Massimo, it turned out the camera that I bought didn't support the onvif commands that I needed, so I put the project on hold. From the old comments in the accept answer, I think there was a problem with the audio codec on the android device that I was trying to use. Hope that helps. – Alain Collins Jul 20 '16 at 15:59

2 Answers2

2

wild-ass-guess on your logcat and the RC=100... No SDP file or no equivalent for RTSP of the 'moov atom' block required to negotiate details of the stream /container/ codec/ format... You can get the AOSP code for mediaPlayer/videoView and grep the RC value in the source.

RTSP is gnarly to debug ( note the tools links ) and not assured to run inside a NAT'd network due to UDP issues. So, to get better result, you may have to look into forcing your config to do data channel on TCP an not UDP. Or it could be other issues , of which there are many.

If you really want to investigate, some possible tools below:

Use command line and CURL client to request your stream:

Android - Java RTSP Session Mgmt package on Git

Protocol dumps for CLI RTSP sessions to Youtube RTSP/SDP streams

To pursue the issue, you may need to get into the weeds with debug tools that track details of the protocol negotiation that preceeds the MediaPlayer actually starting play on the stream. That would include learning the RFP and the protocol details.

Robert Rowntree
  • 6,230
  • 2
  • 24
  • 43
  • From what I can tell, the moov stuff is not for live streaming. See the original comments. – Alain Collins Aug 24 '14 at 16:38
  • The solution is gonna way down under the covers in the protocol or in the details of AOSP code. The details of the session-negotiation, session-setup that you can see in the protcol example link are probably failing somewhere ( port 4 audio, port 4 video, codecs, Packet-type (UDP v TCP)......... ) – Robert Rowntree Aug 24 '14 at 17:05
  • if i were u i would not waste time with RTSP. Try out Web-RTC for a more modern solution to live streams – Robert Rowntree Aug 24 '14 at 17:18
  • 1
    I don't control the feed (it's built into the camera). I just need to consume it. – Alain Collins Aug 25 '14 at 00:55
  • I found some code for mediaplayer.cpp, and the method that prints "error (x,y)" is called with a MEDIA_ERROR value. The (100,0) are ext1 ("Media framework error code") and ext2 ("Implementation dependant error code"), respectively. I believe when ext1=100 it is a "MEDIA_ERROR_SERVER_DIED", which could correlate to the message I'm getting of "AudioFlinger server died!". I'll dig around that some more. – Alain Collins Aug 25 '14 at 01:27
  • I think the clues in this exchange are leading me in the right direction, namely that the audio codec used (G.711) may not be supported. I have to keep digging - and would appreciate continued help - but SO required the awarding of the bounty. – Alain Collins Aug 25 '14 at 08:30
  • if its a missing imple of G.711, you should be able to install the NDK and provide your own codec there. Then you would have to extend / re-implement the player to delegate to that codec on the handler for the audio. – Robert Rowntree Aug 25 '14 at 13:18
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/59942/discussion-between-robert-rowntree-and-alain-collins). – Robert Rowntree Aug 25 '14 at 13:25
0
  1. videoView.setVideoURI(“rtsp://192.1.0.193:554/mpeg4”);
  2. Try your app on another phone.
    You may find the problem is about the mobile device.
  3. Try this path:"rtsp://218.204.223.237:554/mobile/1/4C024DFE77DC717D/onnuvesj43xj7t26.sdp".
    See whether the code has something wrong.
wffger
  • 86
  • 1
  • 9
  • 1. setVideoURI doesn't take a string. – Alain Collins Aug 25 '14 at 00:59
  • 2. As stated above, I tried the app on my tablet and my phone, with the same results. Bother are android 4.4.2, though different manufacturers. – Alain Collins Aug 25 '14 at 01:00
  • 3. That video url works fine. I note that this video uses the "MPEG4-Video (mp4v)" codec and is only 176x144. My camera is outputting "H264 - MPEG-4 AVC (part 10) (h264)" at 1920x1080. More ideas, @wffger? – Alain Collins Aug 25 '14 at 01:14