简体   繁体   English

Android:使用MediaCodec和MediaMuxer录制时裁剪视频

[英]Android: Crop video while recording using MediaCodec and MediaMuxer

I am trying to record the video using GLSurfaceView and audio from the AudioRecord. 我正在尝试使用GLSurfaceView和AudioRecord的音频录制视频。 In MediaMuxer I am sending both audio and video data when onFrameAvailable called. 在MediaMuxer中,我在调用onFrameAvailable时发送音频和视频数据。 I set the camera preview size of 1280 * 720 and preview on the full screen. 我将相机预览尺寸设置为1280 * 720并在全屏幕上预览。 I am having problem to crop the frame to 600 * 600. Can anybody help me to crop the video frame before encoding to MediaCodec and MediaMuxer. 我有问题将帧裁剪为600 * 600.任何人都可以帮我在编码之前裁剪视频帧到MediaCodec和MediaMuxer。

I am taking help from the Grafika android demo code 我正在从Grafika android演示代码中获取帮助

You need to solve to problems: 你需要解决问题:

  1. Record video with 600 * 600: Use video codec with specified width, height. 使用600 * 600录制视频:使用指定宽度,高度的视频编解码器。 This is easy to do, but it could be that not all phones have hardware codecs that will supports you custom resolution. 这很容易做到,但可能并非所有手机都有支持自定义分辨率的硬件编解码器。
  2. Scale video in the way it will look not stretched because you have changed w/h ratio. 缩放视频的方式看起来没有拉伸,因为你已经改变了w / h比率。 Use view matrix passed to OpenGL shader with needed scale. 使用以所需比例传递给OpenGL着色器的视图矩阵。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM