INDExOS / media-for-mobile

Media for Mobile
Other
456 stars 176 forks source link

Video orientation changes to horizontal after transcoding #46

Open EzenwakaKaycee opened 8 years ago

EzenwakaKaycee commented 8 years ago

After transcoding the video orientation changes to horizontal. Even when the original video is in vertical/portrait mode.

xiayouli0122 commented 8 years ago

I have the same question,can someone answer this?

namghiwook commented 8 years ago

Check the RotateEffect!

EzenwakaKaycee commented 7 years ago

I commented the line below in class VideoFormatAndroid https://github.com/INDExOS/media-for-mobile/blob/master/android/src/main/java/org/m4m/android/VideoFormatAndroid.java#L49

It seems to solve the rotation problem for Android 5.0 and above whereas the Problem persist for lower versions such as 4.3 and 4.4 for camera recorded videos

EzenwakaKaycee commented 7 years ago

Is there a way the rotateEffect could be use to resolve this???

CharlieChristensen commented 7 years ago

I solved this by doing the following. When loading the Uri I get the rotation of the image like so:

MediaFileInfo mediaFileInfo = new org.m4m.MediaFileInfo(new AndroidMediaObjectFactory(context));
mediaFileInfo.setUri(videoUri);
mRotation = mediaFileInfo.getRotation();

Then when configuring the video encoder I apply the rotation if necessary

if(mRotation != 0) {
            mMediaComposer.addVideoEffect(new VideoEffect(mRotation, mFactory.getEglUtil()));
        }