Crop video before encoding with MediaCodec for Grafika's “Continuous Capture” Activity

后端 未结 1 688
一整个雨季
一整个雨季 2020-11-30 07:52

I am learning about Grafika\'s \"Continuous Capture\" Activity, It is about recording a video with MediaCodec.

The activity source code is at https://github.com/goog

相关标签:
1条回答
  • 2020-11-30 08:53

    Take a look at the "texture from camera" activity. Note it allows you to manipulate the image in various ways, notably "zoom". The "zoom" is done by modifying the texture coordinates.

    The ScaledDrawable2D class does this; the setScale() call changes the "zoom", rather than scaling the rect itself. Texture coordinates range from 0.0 to 1.0 inclusive, and the getTexCoordArray() method modifies them to span a subset of the texture.

    To clip the frames, you'd need to modify the texture coordinates proportionally. For example, if the input video is portrait 720x1280, and you want 720x720, you would change the coordinates from this:

    [0.0, 0.0]  [1.0, 0.0]
    [0.0, 1.0]  [1.0, 1.0]
    

    to this:

    [0.0, 280/1280.0]  [1.0, 280/1280.0]
    [0.0, 1000/1280.0] [1.0, 1000/1280.0]
    

    and then render that on a square rather than a rectangle.

    0 讨论(0)
提交回复
热议问题