INDExOS/media-for-mobile

Video orientation changes to horizontal after transcoding

Opened this issue · 5 comments

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

I have the same question,can someone answer this?

Check the RotateEffect!

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

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

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()));
        }