-
-
Notifications
You must be signed in to change notification settings - Fork 776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rotation issue for RTMP stream in portrait mode (from surface, off-screen) #1647
Comments
Hello, In your case you only can use GlStreamInterface. Code example: val glInterface = GlStreamInterface(context)
/**start*/
glInterface.setEncoderSize(width, height)
glInterface.setIsPortrait(isPortrait) //should be used, by default false
glInterface.setCameraOrientation(rotation) //should be used, by default 0, you can use this value to rotate on fly
glInterface.forceOrientation(videoSource.getOrientationConfig()) //optional, force landscape or portrait no matter the rotation value. In most of cases you can ignore it.
glInterface.start()
//Send glInterface to the camera, the camera render the surface of glInterface
builder.addTarget(Surface(glInterface.surfaceTexture))
//Add surface of videoEncoder to glInteface, the data received in the glInterface.surfaceTexture is copied into videoEncoder.inputSurface and you can use opengl to modify it as you want
glInterface.addMediaCodecSurface(videoEncoder.inputSurface)
/**stop*/
glInterface.removeMediaCodecSurface()
glInterface.stop() The code example is from this methods: This allow you rotate the image, you can even use filters or add a preview on fly when you want. |
Thank you so much! |
I'm doing RTMP stream from a surface. The problem is, when the phone is in portrait mode, I can't figure out how to rotate the stream by 90 degrees.
Currently I have an encoder, I'm passing its input surface to the capture request builder. It works in landscape mode.
I've checked all previously reported issues here related to rotation, but either couldn't make the solutions from those work, or they weren't applicable since I'm not using a preview display.
Tried below code to rotate using OpenGL before passing to the encoder, but couldn't make it work. I'm not sure if this is the proper way, but it throws an exception in
r.initGl()
with messagecould not compile shader 35633
(tested on multiple phones).Tried
OpenGlView
too but since I'm recording off-screen,surfaceCreated()
is never invoked.I know that if I record to file, I can set media-recorder hint to rotate the output file, but that doesn't apply for streaming.
videoFormat.setInteger(MediaFormat.KEY_ROTATION, 90) doesn't work since according to doc it'll only work if I use an output surface, but then I'll have to read each frame from the output surface and convert those in order to be able to stream. This seems inefficient as instead of using:
I'll then have to listen for each frame of that output surface and process those.
Due to other requirements I can't directly stream from Camera2 using
Root Encoder
.Any ideas on how to proceed?
The text was updated successfully, but these errors were encountered: