Android的webrtc黑屏/绿屏与UV4L流。
创始人
2024-10-07 10:32:26
0

如果在Android上使用webrtc时出现黑屏或绿屏,并且使用UV4L流,请尝试以下解决方法:

  1. 确保正确初始化和配置webrtc库。
PeerConnectionFactory.initializeAndroidGlobals(context, true);
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
DefaultVideoEncoderFactory defaultVideoEncoderFactory = new DefaultVideoEncoderFactory(
    rootEglBase.getEglBaseContext(), true, true);
DefaultVideoDecoderFactory defaultVideoDecoderFactory = new DefaultVideoDecoderFactory(
    rootEglBase.getEglBaseContext());
PeerConnectionFactory.initialize(
    PeerConnectionFactory.InitializationOptions.builder(context)
        .setOptions(options)
        .setVideoEncoderFactory(defaultVideoEncoderFactory)
        .setVideoDecoderFactory(defaultVideoDecoderFactory)
        .createInitializationOptions());
  1. 确保正确设置和配置SurfaceView作为视频显示区域。
SurfaceViewRenderer localRenderer = findViewById(R.id.local_renderer);
localRenderer.init(rootEglBase.getEglBaseContext(), null);
localRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FILL);
localRenderer.setMirror(true);
localRenderer.setZOrderMediaOverlay(true);
localRenderer.setVisibility(View.VISIBLE);
  1. 在创建VideoTrack时,确保正确设置视频源。
MediaConstraints videoConstraints = new MediaConstraints();
videoConstraints.mandatory.add(
    new MediaConstraints.KeyValuePair("maxWidth", "640"));
videoConstraints.mandatory.add(
    new MediaConstraints.KeyValuePair("maxHeight", "480"));
videoConstraints.mandatory.add(
    new MediaConstraints.KeyValuePair("maxFrameRate", "30"));

VideoCapturer videoCapturer = UV4LCapturer.create(
    uv4lServerUrl, uv4lUsername, uv4lPassword, videoConstraints);

VideoSource videoSource = peerConnectionFactory.createVideoSource(videoCapturer.isScreencast());
videoCapturer.initialize(
    surfaceTextureHelper, context, videoSource.getCapturerObserver());
videoCapturer.startCapture(
    videoConstraints.mandatory.get("maxWidth"),
    videoConstraints.mandatory.get("maxHeight"),
    videoConstraints.mandatory.get("maxFrameRate"));

VideoTrack videoTrack = peerConnectionFactory.createVideoTrack("videoTrack", videoSource);
videoTrack.addSink(localRenderer);

确保正确设置UV4L服务器的URL、用户名和密码,并根据需要调整视频的最大宽度、高度和帧率。

这些解决方法应该能够帮助您解决Android上使用webrtc和UV4L流时的黑屏或绿屏问题。请根据您的具体情况进行适当的调整和修改。

相关内容

热门资讯

推荐一款!hhpkoer辅助器... 推荐一款!hhpkoer辅助器视频,wepoker破解版内购,AI教程(有挂技巧);致您一封信;亲爱...
透视总结"wepok... 透视总结"wepoker透视脚本视频"详细辅助力荐教程(原生存在有挂);建议优先通过wepoker透...
透视玄学"wepok... 这是一款非常优秀的wepoker怎么设置房间 ia辅助检测软件,能够让你了解到wepoker怎么设置...
分享开挂内幕!德州局透视脚本免... 分享开挂内幕!德州局透视脚本免费版下载手机版,wepoker私人局俱乐部,2025版教程(有挂方法)...
透视挂透视"aapo... 透视挂透视"aapoker辅助器怎么用"详细辅助爆料教程(往昔有挂)这是由厦门游乐互动科技有限公司精...
信息共享!hhpoker辅助,... 信息共享!hhpoker辅助,wepoker有没有插件,德州论坛(有挂软件);《WPK辅助透视》‌:...
透视软件"wepok... 此外,数据分析德州(wepoker私人局可以透视)辅助神器app还具备辅助透视行为开挂功能,通过对客...
信息共享!wepoker有没有... 信息共享!wepoker有没有透视方法,hhpoker辅助器视频,必赢教程(有挂软件);1.wepo...
透视有挂"智星德州插... 透视有挂"智星德州插件"详细辅助细节揭秘(切实是有挂)1、很好的工具软件,可以解锁游戏的ai质量和中...
重大科普!hhpoker脚本下... 重大科普!hhpoker脚本下载,德州机器人代打脚本,辅助教程(有挂透明);德州机器人代打脚本软件透...