Unity3D WWW类在抓取mjpegs时产生黑色和金色的乐队

时间:2013-10-26 19:27:45

标签: c# unity3d mjpeg

enter image description here我正在尝试从mjpeg流服务器获取视频供稿。客户端在c#,Unity3D中。每当我运行它时,我会得到一个黑色和金色乐队的奇怪图像。

我知道这不是服务器的问题,因为处理库IPCapture可以很好地获取图像。enter image description here

我将以下c#代码附加到Unity3D中的一个平面:

使用UnityEngine; 使用System.Collections;

public class IPCapture : MonoBehaviour {
    string url = "http://192.168.0.106:8081/video.mjpg?q=30&fps=33&id=0.7494465354830027&r=1382760993848";
    // Use this for initialization
    void Start () {
        renderer.material.mainTexture = new Texture2D(4, 4, TextureFormat.DXT1, false);
        WWW www = new WWW(url);
        StartCoroutine(SetTextures(www));
    }

    public IEnumerator SetTextures(WWW www){
        yield return www;
        renderer.material.mainTexture = www.texture as Texture2D;
    }
    // Update is called once per frame
    void Update () {

    }
}

0 个答案:

没有答案