我在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类
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模式启动,有时以软件启动。有没有什么可以导致这种情况?
答案 0 :(得分:1)
Hacky但是它有效。
如果要进行软件渲染,请停止并重新启动视频,直到它在GPU上呈现为止。似乎只需要几次。