Android视频录制,自定义视频大小,支持触摸对焦、两指放大缩小、切换摄像头. 采用FFmpeg对进行视频帧剪裁旋转切割,包体积4M
功能简介:
- 视频录制、播放
- 自定义视频大小
- 翻转摄像头、翻转后图像翻转功能
- 触摸对焦、两指放大缩小
参考开源项目:
javacv - 使用opencv+ffmpeg,功能最完整的项目,可以用于拓展参考
RecordVideoDemo - 参照javacv中的Demo使用camera+ffmpeg实现,本项目基于该开源项目开发
VideoRecorder - 也是一个不错的录制视频项目,不过so库已经太旧了,sdk超过22无法通过
在gradle中添加
...
dependencies {
...
compile 'com.tsy.video:video-sdk:1.0.0'
}
...
具体代码见app中的RecorderActivity
//初始化摄像头
mCamera = CameraHelper.getCamera(this, mCameraFace); //默认打开后置摄像头
//初始化摄像预览界面
mCameraPreviewView = (CameraPreviewView) findViewById(R.id.camera_preview);
mCameraPreviewView.init(mCamera, RECORDER_WIDTH, RECORDER_HEIGHT);
//初始化recorder
mRecorder = new Recorder.Builder()
.context(getApplicationContext())
.camera(mCamera)
.cameraFace(mCameraFace)
.outputSize(RECORDER_WIDTH, RECORDER_HEIGHT)
.outputFilePath(path)
.build();
mRecorder.start();
mRecorder.stop();
if(mCameraFace == Camera.CameraInfo.CAMERA_FACING_BACK) {
mCameraFace = Camera.CameraInfo.CAMERA_FACING_FRONT;
} else {
mCameraFace = Camera.CameraInfo.CAMERA_FACING_BACK;
}
mCamera = CameraHelper.getCamera(this, mCameraFace);
mCameraPreviewView.switchCamera(mCamera);
mRecorder.switchCamera(mCamera, mCameraFace);
mRecorder.isRecording()
mRecorder.getRecordingTime()
简书地址:http://www.jianshu.com/users/21716b19302d/latest_articles
微信公众号
Copyright 2017 SY.Tang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.