VideoTexture 降级为软件 Rendering in Air

VideoTexture downgrades to software Rendering in Air

我是 运行 Away3D 中的 VideoTexture,它通常运行良好。我一直在尝试减少视频之间的黑色间隙并试图让它们很好地排列,但是我的尝试导致视频有时会降级为移动设备上的软件渲染,尤其是当它第一次启动时。

我将 Away3D 与 Starling 和共享的 stage3DProxy 一起使用。

这是我设置视频的方法

            sphereGeometry = new SphereGeometry(5000, 64, 48);
            panoTexture2DBase = new NativeVideoTexture(Model.config.getAssetUrl(Model.currentScene.video), true, true);

            panoTexture2DBase.addEventListener(NativeVideoTexture.VIDEO_START,function(e:Event =null){setTimeout(onVideoStart,1000)});
            panoTextureMaterial = new TextureMaterial(panoTexture2DBase, false, false, false);

            panoVideoMesh = new Mesh(sphereGeometry, panoTextureMaterial);
            panoVideoMesh.scaleX *= -1;

            panoVideoMesh.rotate(Vector3D.Y_AXIS,-90);

            scene.addChild(panoVideoMesh);
            view.render();

            panoTexture2DBase.player.pause();

我使用 Away3d NativeVideoTexture 加载网络流。后面的视频一般没问题,硬件加速。它只是第一个总是降级的。

我的 NativeVideoTexture class

override protected function createTexture(context:Context3D):TextureBase
    {
        try
        {
            trace("Context3D.supportsVideoTexture", Context3D.supportsVideoTexture)

            if (!Context3D.supportsVideoTexture)
            {
                throw new Error("flash.display3D.textures.VideoTexture not supported");
                return null;
            }

            texture = context.createVideoTexture();
            texture.attachNetStream(_player.ns);

            _player.ns.addEventListener(NetStatusEvent.NET_STATUS, netstat);
            _player.ns.seek(1);
            texture.addEventListener(Event.TEXTURE_READY, onTextureReady);
            texture.addEventListener(VideoTextureEvent.RENDER_STATE, onRenderState);

            if (_autoPlay) _player.play();

        }
        catch (e:Error)
        {
            trace(e, e.getStackTrace());
        }

        return texture;
    }

    private function onMetaData(metaData:Object):void
    {
        duration = metaData.duration;  

    }

    private function onTextureReady(e:Event):void
    {
    //  trace("NativeVideoTexture.onTextureReady()");
        if(_player.duration)
            if(_player.ns.time > _player.duration - 1){
                _player.pause();
                dispatchEvent(new Event(VIDEO_STOP));
                _player.seek(0);
            }
            else if(_player.ns.time > 0.01 && waitingForBuffer){
                dispatchEvent(new Event(VIDEO_START));
                waitingForBuffer = false;
            }

    }




    private function onRenderState(e:VideoTextureEvent):void
    {
        trace(e.status);
        if (e.status == VideoStatus.SOFTWARE)
        {
            trace("Indicates software video decoding works.")
        }
        if (e.status == VideoStatus.ACCELERATED)
        {
            trace("Indicates hardware-accelerated (GPU) video decoding works.")
        }
        if (e.status == VideoStatus.UNAVAILABLE)
        {
            trace("Indicates Video decoder is not available.")
        }
    }

谁能帮我弄清楚为什么第一个视频总是软件渲染?

编辑:我取得了一些进步

有时以 GPU 模式启动,有时以软件模式启动。有什么会导致这种情况吗?

Hacky 但它有效。

如果要进行软件渲染,请停止并重新启动视频,直到它在 GPU 上渲染。似乎只需要几次。