livekit / client-sdk-android

LiveKit SDK for Android
https://docs.livekit.io
Apache License 2.0
174 stars 69 forks source link

after enabling H264 in HardwareVideoEncoderFactory, screen sharing cannot proceed normally #245

Closed wzJun1 closed 1 year ago

wzJun1 commented 1 year ago

Describe the bug

Cause of the incident: Due to the black screen and jamming of the camera on Huawei HarmonyOS 3, I saw a similar issue and resolved the issue with this camera: [issue 179](https://github.com/livekit/client-sdk-android/issues/179#issuecomment -1506657055)

But as a result, new problems have also emerged.

when I enable the following configuration, other devices (such as Oneplus, Oppo, Xiaomi) cannot decode screen sharing published by other devices.

room = LiveKit.create(
    applicationContext,
    overrides = LiveKitOverrides(
        audioHandler = audioHandler,
        videoEncoderFactory = HardwareVideoEncoderFactory(
            EglBase.create().eglBaseContext,
            false,
            true,
        ),
    ),
    options = options
)

But if I don't use 'HardwareVideoEncoderFactory', then on HarmonyOS 3 devices, the camera may experience blurred or black screens, or it may get stuck after frequent camera switching (guessing decoding issues). So in order to ensure camera issues, I must use 'HardwareVideoEncoderFactory'.

If I use 'if' to distinguish between HarmonyOS 3 and other device systems and use 'videoEncoderFactory' according to different brands, there will still be a problem where HarmonyOS 3's screen sharing cannot be decoded by other devices (black screen)

In summary, this is a problem that I don't know how to solve

Device Info:

davidzhao commented 1 year ago

I think the better thing to do is to:

wzJun1 commented 1 year ago

I think the better thing to do is to:

  • do not override to HardwareVideoEncoderFactory
  • publish videos with VP8 instead of H.264

    • this can be done either via changing it in your project settings (or config.yaml if self-hosting)
    • or setting videoCodec to vp8 in VideoTrackPublishOptions here

Thank you for your reply. I will give it a try

wzJun1 commented 1 year ago

@davidzhao It has been resolved, thank you!

RXlung commented 2 months ago

已经解决了,谢谢!

请问您具体怎么解决的黑屏,我遇见了录制本地视频的时候出现黑屏,6台设备,只有一台可以录制。其他全黑屏,直接运行的demo