pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.56k stars 773 forks source link

Display RTMP doesn't fit screen #819

Open linhlq58 opened 3 years ago

linhlq58 commented 3 years ago

I'm working on an app which is live-streaming on Facebook using Display RTMP. But I noticed that the output video don't fit the screen, there are black spaces on 2 sides. I think this issue happens when screen size of device does not match with resolution (720 x1080).

Is there any way to capture only a part of screen and stream to Facebook to avoid this issue?

photo_2021-04-02_18-06-40

pedroSG94 commented 3 years ago

Hello,

Display mode support any resolution. If you select a resolution different of device screen MediaProjectionManager scale it for you.

linhlq58 commented 3 years ago

@pedroSG94 Yes, but the output video will not be at fullscreen. I want a fullscreen video without any black spaces. Are there any options to trim screen before streaming? Or a way to fit screen width and auto scale screen height?

pedroSG94 commented 3 years ago

This is not a bug, I tried record screen with native oneplus app and the result is the same (black spaces). I suspect that mediaprojection api is doing it (I mean it is already full screen). We can apply a filter to crop it. Knowning it the question is:

I will check it another time to comfirm all

linhlq58 commented 3 years ago

Okay 👯 Please let me know when you have a solution. I really need your help.

pedroSG94 commented 3 years ago

Ok, I found a way to fit screen but this produce image distortion to adapt it (it is normal you can't fit without distortion using different resolutions). Go to this line and set width / height to screen device resolution: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/rtplibrary/src/main/java/com/pedro/rtplibrary/base/DisplayBase.java#L392 Also in this line: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/encoder/src/main/java/com/pedro/encoder/input/gl/render/CameraRender.java#L68

linhlq58 commented 3 years ago

@pedroSG94 Thank you for your solution. I tried and it worked. But it's a bad UX in a livestream app if images are distorted. Is there anyway to fit screen without distortion by cutting the top edge or bottom edge of the screen while streaming?

pedroSG94 commented 3 years ago

Yes, that is possible but, for now, I will mark it as feature because it will take time to develop properly.

hoangcongtuan commented 3 years ago

Hi @linhlq58, do you have any solution for this?