MasayukiSuda / CameraRecorder-android

Video Recording with Camera2 and apply video filter.
MIT License
254 stars 73 forks source link

Video rotation help #26

Open WangYP90 opened 4 years ago

WangYP90 commented 4 years ago

Hello, if I need to rotate the video with an angle to save it as a file when recording on a horizontal screen, what should I do? I look forward to your help.

hellojiawa commented 3 years ago

下面步骤可以在横屏模式下录制竖屏视频:

  1. GlPreviewRenderer类创建一个新的MMatrix2

    private float[] MMatrix2 = new float[16];
    Matrix.setIdentityM(MMatrix2, 0);
  2. 修改编码部分代码

        synchronized (this) {
            if (videoEncoder != null) {
                Matrix.multiplyMM(MVPMatrix, 0, VMatrix, 0, MMatrix2, 0);
                Matrix.multiplyMM(MVPMatrix, 0, ProjMatrix, 0, MVPMatrix, 0);
    
                // notify to capturing thread that the camera frame is available.
                videoEncoder.frameAvailableSoon(texName, STMatrix, MVPMatrix, aspectRatio);
            }
        }
  3. MediaVideoEncoder类的fileWidth和fileHeight互相调换

ToysoftInc commented 3 years ago

Do you have a working example that you can post or share? I'm trying to do the same thing. Rotate video 90 degrees.