简体   繁体   English

从服务器到Android的实时mjpeg视频流

[英]Live mjpeg video stream from server to android

I am trying to fetch mjpeg live video stream from server to android.I read this answer.it is very helpful to me.It works with this demo url.But, In my video stream it asking for username and password. 我正在尝试从服务器到android提取mjpeg实时视频流。我读了答案。它对我很有帮助。它与演示网址配合使用。但是,在我的视频流中它要求用户名和密码。

To set url into MjpegView: 要将网址设置为MjpegView,请执行以下操作:

 setContentView(mv);        
 mv.setSource(MjpegInputStream.read(URL));

MjpegInputStream: MjpegInputStream:

public static MjpegInputStream read(String url) {
    HttpResponse res;
    DefaultHttpClient httpclient = new DefaultHttpClient();     


    try {
        res = httpclient.execute(new HttpGet(URI.create(url)));
        return new MjpegInputStream(res.getEntity().getContent());              
    } catch (ClientProtocolException e) {
    } catch (IOException e) {}
    return null;
}

As in web browser whenever i open my server link..it asking for 'password' & 'username'.so where to put params in this read() ? 就像在网络浏览器中一样,每当我打开服务器链接时,它都会要求输入“ password”和“ username”。因此在此read()中将参数放在哪里? and also want to know if my live video is in H.264 format. 并且还想知道我的实时视频是否为H.264格式。 then how can i convert it into MJPEG format?Also its speed is very slow and not smooth.how to improve it? 那我怎么能把它转换成MJPEG格式呢?它的速度很慢而且不流畅,如何改善呢?

Thanks in Advance!! 提前致谢!!

You are promted for a login because the webcam is password protected. 由于网络摄像头受密码保护,因此提示您登录。 Normally with webcams you have to pass the username and password as part of the URL. 通常,使用网络摄像头时,您必须将用户名和密码作为URL的一部分传递。 eg. 例如。 username:password@ip.address.or.dyndns.com:8085/folder/stream.jpg?size=large where the number at the end is the port number. username:password@ip.address.or.dyndns.com:8085 / folder / stream.jpg?size = large其中末尾的数字为端口号。

it's been a time... but to login: 已经有一段时间了...但是要登录:

DefaultHttpClient httpclient = new DefaultHttpClient();
    try {

        HttpGet httpget2 = new HttpGet(url);
        httpget2.addHeader("Authorization","Basic " + Base64.encodeToString((USERSTRING:PASSWORDSTRING).getBytes(),Base64.DEFAULT));
        res = httpclient.execute(httpget2);
        return new MjpegInputStream(res.getEntity().getContent());

    } catch (ClientProtocolException e) {

        e.printStackTrace();

    } catch (IOException e) {

        e.printStackTrace();
    }

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

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