直播mjpeg视频流从服务器到android

时间:2013-07-22 05:52:44

标签: android video-streaming mjpeg

我正在尝试将mjpeg实时视频流从服务器提取到android.I阅读this answer.it对我非常有用。它与this demo url.But一起工作,在我的视频流中它要求用户名和密码。

将url设置为MjpegView:

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

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;
}

在网络浏览器中,每当我打开我的服务器链接时......要求'密码'和& “username'.so 在这个read()中放置params的位置?并且还想知道我的直播视频是否在 H.264 中 格式。那我怎么能把它转换成 MJPEG 格式呢?它的速度也很慢而且不平滑。如何改进呢?

先谢谢!!

2 个答案:

答案 0 :(得分:1)

您被要求登录,因为网络摄像头受密码保护。通常使用网络摄像头,您必须将用户名和密码作为URL的一部分传递。例如。用户名:password@ip.address.or.dyndns.com:8085 / folder / stream.jpg?size = large,最后的数字是端口号。

答案 1 :(得分:0)

这是一段时间......但要登录:

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();
    }
相关问题