2

libstreaming works fine - in landscape mode. Unfortunately, my app will have to run in portrait mode. No problem for the preview window - I can set it upright with

session.setPreviewOrientation(90);

But the receiver of the stream will still have the video sideways. Is there a solution for that?

In Android's Mediarecorder, there is a method setOrientationHint(int degrees) that will rotate the streamed/recorded video. But I did not find anything like that in libstreaming...

user611923
  • 143
  • 8
  • what streaming method are you using? I think I had the same problem and when I changed to `mSession.getVideoTrack().setStreamingMethod(MediaStream.MODE_MEDIACODEC_API_2);` it solved the problem – SERPRO Feb 25 '16 at 11:47
  • @SERPRO can you elaborate more about it? – Hardy Apr 02 '18 at 10:20

2 Answers2

1

I have encountered this problem before. There are 3 possible solutions that I implemented.

  1. Convert each YUV frame that comes out from onPreviewFrame API to a bitmap then rotate the bitmap and finally convert the bitmap back to YUV frame. The disadvantage of this solution is video frame has been dropped alot (in my case from 24 to 4-5 FPS).

  2. Rotate each YUV frame 90/270 degrees (based on orientation of camera) clockwise using code from here. The disadvantage of this solution are images will be distorted and video frame might be dropped as well.

  3. Using an open source library from Google called libyuv. If you have knowledge of JNI, it will be easy for you. BTW, you can see demo about this lib here and here. Because rotation process handled at native layer so this is efficient solution and the best one so far.

Hope this info will be helpful for anyone who are encountering with this problem.

Son Truong
  • 13,661
  • 5
  • 32
  • 58
-1

Change the video quality to (1280,720) from (320,240). Then once you start it should be changed and rotated. BTW how did you implement your receiver?