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.52k stars 768 forks source link

[Question] video Orientation problem #852

Closed francescogatto closed 6 months ago

francescogatto commented 3 years ago

Hi!

I have some problem with orientation. I'm using your library in a SmartGlasses that supports only landscape resolution. I can see the video local correctly, but when i send it to the rtmp server, it is always in portrait and stretched. Here my code:

` override fun surfaceChanged(surfaceHolder: SurfaceHolder, i: Int, i1: Int, i2: Int) { rtmpCamera2.startPreview(1280 ,720 ) Handler().postDelayed({startStream()}, 200)

}`

fun startStream() { if (!rtmpCamera2.isStreaming) { if (rtmpCamera2.isRecording || rtmpCamera2.prepareAudio() && rtmpCamera2.prepareVideo(1280 ,720 , 27,5000 * 1024,90 )) { rtmpCamera2.startStream(etUrl) } else { Toast.makeText( this, "Error preparing stream, This device cant do it", Toast.LENGTH_SHORT ).show() } } }

<com.pedro.rtplibrary.view.OpenGlView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/surfaceView" app:keepAspectRatio="false" app:aspectRatioMode="fill" app:AAEnabled="false" app:numFilters="1" app:isFlipHorizontal="false" app:isFlipVertical="false" />

Thanks a lot for the support, you are doing a nice work with this library

pedroSG94 commented 3 years ago

Hello,

The best way seem to be lock activity in landscape for smartglasses and set rotation to 0 in the library. To lock screen you can do something similar to this in onCreate:

if (smartglasses()) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);