11

I'm new to Android development and can't seem to get anywhere with the development of an app to live stream an RTSP feed from an ip camera. While I can get the code to stream from a website with an RTSP address of a .mov file, I cannot get it to stream from my ip camera's RTSP address. We are using VideoView so that we can support back to android 4.0 because the goal is to display this in Epson Moverio BT-200 video glasses.

Below is the code I have now, with lines to the two streams I can get from the camera commented out. The line not commented out is a test stream online that plays fine.

VideoView videoView;
@Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    //Create a VideoView widget in the layout file
    //use setContentView method to set content of the activity to the layout file which contains videoView
    this.setContentView(R.layout.activity_full_screen_video);
    videoView = (VideoView)this.findViewById(R.id.video_player_view);

    //Set the path of Video or URI
    //videoView.setVideoPath("rtsp://192.168.1.122/h264");
    //videoView.setVideoPath("http://192.168.1.122/ipcam/mjpeg.cgi");
    videoView.setVideoPath("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov");

    //Set the focus
    videoView.requestFocus();
    videoView.start();
}

When ran with either of the lines that are pulling from the ip camera, we get the error below:

'setDataSource IOException happend :
java.io.FileNotFoundException: No content provider: http://192.168.1.122/ipcam/mjpeg.cgi'

The RTSP stream from the camera has been verified with another rtsp android app, so I know it's not bad.

Does something have to be done to allow for buffering? The ultimate goal is to get as close to real time live streaming to the app to do video overlay in the glasses. However, we can't even get a basic stream to show up. Any and all advice would be welcome!

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
kfilbrun
  • 123
  • 1
  • 6
  • Have you tried supplying Uri instead of String as path? – Nikola Despotoski Dec 18 '14 at 04:10
  • I've done both, although I have not done extensive testing with both. It works fine with string as displayed now from the demo BigBuckBunny stream, so I can't imagine that would change between that stream and the ip camera stream(s) (commented out) and cause this type of issue. – kfilbrun Dec 18 '14 at 04:20
  • try 'localhost'. from the error, there may be some issue with the loopback on the local network. ( no content provider ? ) OR experiment with SDP for the local stream with IP cam. Can you construct SDP file to represent the stream from camera and start a view/mediaPlayer on that? more on SDP list at http://snipplr.com/view/57846/curl--rtsp-to-get-sdp-descriptor-for-media-stream/ – Robert Rowntree Dec 20 '14 at 02:22
  • Just some thoughts: Does the stream from the IP Cam need authentication? Is it possible that rtsp on the camera is on a different port? Often it is something like 554 etc. (or in your case possibly `"rtsp://192.168.1.122:554/h264"`, ..). – Levite Jan 21 '15 at 14:26
  • 1
    @user1761017 did you resolve this issue? I'm seeing this same message related with content provider in my app. – androidevil Feb 10 '15 at 18:28
  • @Levit I'm facing the same problem, and yes, the stream from the IP Cam need authentication, so how to provide that authentication?!!!! refer to my question here http://stackoverflow.com/questions/31453747/cant-receive-rtsp-live-stream-from-an-ip-cam – Muhammed Refaat Jul 16 '15 at 12:25
  • Unfortunately I laid this project down a long time ago and never managed to resolve the problem. Sorry I haven't been able to help more! – kfilbrun Nov 09 '18 at 17:45
  • I can confirm that I'm running into a similar issue. Using the test stream of `rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov` works fine but, in my case, using a local network RTSP server produces an error. Looking into it further and then will post an answer here for others. – Joshua Pinter Feb 03 '19 at 20:05

1 Answers1

2

I can confirm that I'm running into a similar issue.

In my case, I'm using a local network RTSP server to serve a file called camera.ts with the following RTSP URL:

rtsp://macpro.local:8554/camera.ts

It produces a Can't play this video error:

Can't play this video error.

I wanted to see if there was a permissions issue or something so I tried the test RTSP url.

rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov

Works fine.

So that means it's not a permissions issue. Might be a network issue so let's see if I can get that same BigBuckBunny movie file playing through my RTSP server.

I downloaded that BigBuckBunny movie, converted it to .mkv and tried that.

rtsp://macpro.local:8554/big_buck_bunny.mkv

Works fine.

So that kinda rules out a permissions issue and rules out a network issue or an issue with my server.

My guess is to start honing in on the file type. Perhaps the .ts filetype is giving it trouble.

.ts file extension.

This is the error message I'm seeing in the logs:

D/MediaPlayer: setDataSource IOException happened : 
    java.io.FileNotFoundException: No content provider: rtsp://macpro.local/camera.ts

But, that might be a Red Herring because if I look at the logs when I try and play the test file, which works, I get the same thing:

D/MediaPlayer: setDataSource IOException happend : 
    java.io.FileNotFoundException: No content provider: rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov

So let's rule that out and keep looking....

Update: I never did find a solution to this. I abandoned trying to view the RTSP stream and only recorded it using ffmpeg instead, which is all that we required for our presentation demo. If you find out a proper solution or Android adds better support, please post it here.

Joshua Pinter
  • 45,245
  • 23
  • 243
  • 245