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
Video stream orientation the receiver side #36
Comments
Hi, You would need to rotate the video on the receiver side! There is nothing implemented right now to rotate the video before encoding it. When using the MediaRecorded API (On android ICS) to get encoded video from the phone, the video is recorded in lanscape. When recording to a file, the API adds some information to indicated to the decoder that the video has to be rotated, when using this API for streaming, this information is lost (It should be be in the moov atom of the MP4 file...) When using the MediaCodec API with the Buffer to Buffer method, you could try to rotate the NV21 images that you get from the camera but my guess is that you can't do that quickly enough with plain java, maybe a render script (GPU only used on some phone from what I read) or some C (JNI is slow though) could do the trick. The best hope to achieve this would be to use the MEdiaCodec API with the surface to buffer method, did you check if that was working on your phone? You will need this to try it: In that case, it may be possible to ask the GPU to rotate the texture obtained from the camera, I don't know how though, but it may not be complicated with the right OpenGL calls... If someone could add this it would be awesome. |
Hi i want the recorded video in portrait mode, i did change mSession.getVideoTrack().setStreamingMethod(MediaStream.MODE_MEDIARECORDER_API); and the VideoStream.java by adding the following line mMediaRecorder.setOrientationHint(90);. Now i'm getting an error on mMediaRecorder.setOutputFile(mSender.getFileDescriptor()); All i require is to play this landscape video in portrait mode at the server side. |
I haven't been able to solve this problem yet either... |
Is there anyone here has a solution for this issue..? |
Is anyone solved this issue ? |
Still no solution... |
I am afraid that Wowza ignores the orientation hints for incoming video, therefore if you cannot control the receiver side, you are stuck with one of the methods described above. |
@alexcohn It is really hard with OpenGL calls and since i'm a beginner to the android i'm not so sure about such stuff. Moreover fyhertz is not sure about that method. Are you able to find a solution with that method. |
Hi Friends!! Did you got any solutions for the same? Also want to display live broadcasted video in portrait mode while streaming . Please suggest and share if you guys having any solution in OpenGL also.. |
Hi Friends, When I broadcast any live video from android and see the video on other side its resolution not looks good, can you please suggest to improve resolution of video. Thanks, |
any solution? |
any solution ? |
In VideoStream class change mOrientation = 90; |
Explore "libstreaming" library then go to:
|
Thank you tneglnareb but unfortunately it didn't rotate or change anything when I tried as you guided. |
Hi Guys, I have resolved it by rotating the frame before sending it.I have made the camera full screen and with portrait stream. Here is my lib I am using android basic surface view <android.support.v4.view.ViewPager Mail me if you are facing any issue : cvofjaspreet@gmail.com, jaspreet.android@gmail.com |
@cvofjaspreet: Thank you! I got this on Serverside (Wowza server) when trying to use the lib you have linked above. It was OK with the original libstreaming before. Also I see errors (null point & camera is being used after released) in Android Studio Logcat. You have any idea? BTW I have commented out a couple of lines in VideoStream.java (related to ChatActivity) -16 19:57:03.366 26360-27345/kr.co.mediapeople.rtsptestclient W/System.err﹕ java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaRecorder.stop()' on a null object reference |
Or you could simply let me know where to change in source code in order to make camera rotate. Thanks in advance. |
Hi, Here is code to rotate. In VideoStream.java Camera.PreviewCallback callback = new Camera.PreviewCallback() {
public static void rotateNV21(byte[] input, byte[] output, int width, int height, int rotation) { In MediaStream.java
// encodeWithMediaRecorder(); |
Hi, You must be using old version of lib. Has Sent from my iPhone
|
Hi Has, Thank you so much. Indeed it works perfectly! One thing I am still working on is to prevent mirrored frames when I use front-facing camera. If I do 90 degree rotation with video frames generated from the front-facing camera, on the receiving-end, video frames are upside down. So, wondering if you have any idea or a solution for this. Anyway, it's been great help already! Thanks in advance. |
Hi David, I am working on Front camera. I will let you know If I face the issue,but you can modify that method to rotate 180. @brunosiqueira can you close the issue ? Jas |
Hi Guys, Thank you, @cvofjaspreet your code helped me a lot. But I got another issue. When I switch the camera, the stream lose the image, but the audio still works. Michel |
Hi Guys, @michelrbr I have not worked on front camera till now. Any buddy set video quality dynamically depending on device camera supported resolutions ? I have set it static Jas |
Hey @cvofjaspreet |
@cvofjaspreet you code is working fine but it is not that stable it seems.Specially when you are changing resolutions video does not stream properly to the player(like above screen). Is it possible to get a more robust solution for this. Also is there any solution for front camera issue ?? |
Hi Guys, I was also having few issues at that time but now I am done with the project. I can't share the code as its confidential with my client. My app We have not done any advertisements as we are still testing it. I can help you if you are facing issue and that issue is not there in my app. My Skype |
@cvofjaspreet I try your way but the picture's color is close purple when you decode |
Hi guys, The code provided by @cvofjaspreet works, the images is rotating but the with still the same. Anyone have a solution to obtain fully rotaed image 177x144 ? I've been working with libyuv but didn't help a lot. |
@dvidz Do you want to rotate the frame by 90 or 180? Here is the code I enable when the preview orientation is 180 or 270. I don't mind if the picture is mirrored since 95% of users use surface method. |
@sbaar I m using This fonction to rotate the bytes but if anyone Knowles how to deal with to inverse width and heigth with This, it would be very usefull. Hey guys have u found the solution ? |
If, for example, the preview is 640x480 in portrait, then setting the rotation to 90 will cause the opengl to receive a 480x640. |
Gave up this Lib |
hi @cvofjaspreet u know u are a life savor wish i could do some thing for u. Its ur Day today :) 👍 |
Lib streaming library is not working with marshmallow how can we solve it. Actually i am not getting where is issue my code is looking fine but i didn't get what is actually issue. Please Help. |
@dvidz I finally solved the problem, you must set the quality 144x177 and then in @cvofjaspreet solution change the rotateNV21 method in this way: get the camera frame that is still 177x144 convert it to bitmap and then rotate it then again convert it to NV21 and put it in the buffer ;) |
@cvofjaspreet thanks in advance for your last solution. Is there any similar solution to manipulate the frame in API2 ? as I investigated we can not use dequeueInputBuffer() in method 2, so how we can do the same thing in method2? |
I've been trying to stream videos to wowza in portrait mode. Setting preview orientation doesn't seen to have any effect. Is there any correction available to make it work?
The text was updated successfully, but these errors were encountered: