简体   繁体   English

流wifi摄像头到Android

[英]stream wifi camera to android

I'm trying to display the video stream from my wifi camera (SJ6 Legend) to an Android device. 我正在尝试显示从wifi摄像头(SJ6 Legend)到Android设备的视频流。

When turning on the wifi from the camera and connecting to its network from my mac I can see the video stream from vlc simply by going to File -> Open Network and connecting to rtsp://MY_CAM_IP. 从相机打开wifi并从Mac连接到它的网络时,只需转到File-> Open Network并连接到rtsp:// MY_CAM_IP,就可以看到来自vlc的视频流。

I then connect to the wifi from my android device and I tried using MediaPlayer or VideoView and it doesn't work. 然后,我从我的android设备连接到wifi,并尝试使用MediaPlayerVideoView ,但它不起作用。

vlc for android also doesn't display the video. 适用于Android的vlc也不会显示视频。

Just to make sure there is no problem playing RTSP I tried this file: rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov 为了确保在播放RTSP时没有问题,我尝试了以下文件:rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov

and it works fine on vlc for android and using MediaPlayer . 它在适用于android的vlc上并使用MediaPlayer

I also tried a vlc for android lib, that didn't work as well... 我还为Android lib尝试了vlc,但效果不佳...

Relevant code: 相关代码:

In onCreate: 在onCreate中:

SurfaceView surfaceView = (SurfaceView) 
findViewById(R.id.am_surface_view);
mSurfaceHolder = surfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setFixedSize(320, 240);

and: 和:

/**
 * {@link MediaPlayer.OnPreparedListener} interface methods
 */
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
    mMediaPlayer.start();
}

/**
 * {@link SurfaceHolder.Callback} interface methods
 */
@Override
public void surfaceChanged(final SurfaceHolder holder, final int format, final int width, final int height) {}

@Override
public void surfaceCreated(SurfaceHolder sh) {

    mMediaPlayer = new MediaPlayer();
    mMediaPlayer.setDisplay(sh);

//    Context context = getApplicationContext();
//    Map<String, String> headers = getRtspHeaders();
//    Uri source = Uri.parse(RTSP_URL);

    try {
        // Specify the IP camera's URL and auth headers.
//        mMediaPlayer.setDataSource(context, source, headers);
//        mMediaPlayer.setDataSource(context, source);
        mMediaPlayer.setDataSource(RTSP_URL); // RTSP_URL = "rtsp://MY_CAM_IP"

        // Begin the process of setting up a video stream.
        mMediaPlayer.setOnPreparedListener(this);
        mMediaPlayer.prepareAsync();

    } catch (Exception e) {}
}

@Override
public void surfaceDestroyed(SurfaceHolder sh) {
    mMediaPlayer.release();
}

Anyone can point me to some solution??? 任何人都可以向我指出一些解决方案???

Thanks 谢谢

It finally worked when I turned off the phones' cellular network data. 当我关闭手机的蜂窝网络数据时,它终于可以工作了。

Unfortunately I need to receive the camera stream and have a network connection to send the frames received but I guess that's another question... 不幸的是,我需要接收摄像机流并具有网络连接来发送接收到的帧,但是我想这是另一个问题...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM