**
我尝试将位图(ip-camera)转换为来自OpenCV的视频。
它执行了打开和释放操作,但是我的视频是0 B。
我应该尝试哪个方向? 还是我缺少哪一部分? **
private void videoW(Bitmap bitmap) {
if (isRecord) {
mat = new Mat(bitmap.getWidth(), bitmap.getHeight(), CvType.CV_8UC3);
if (mVideoWriter == null) {
try {
FileWriter fileWriter = new FileWriter(Environment.getExternalStorageDirectory()+"/Test/video.avi");
} catch (IOException e) {
e.printStackTrace();
}
mVideoWriter = new VideoWriter(recordfilepath(), VideoWriter.fourcc('M', 'P', '4', '2'), 30.0D, mat.size());
mVideoWriter.open(recordfilepath(), VideoWriter.fourcc('M', 'P', '4', '2'), 30.0D, mat.size());
}
if (!mVideoWriter.isOpened()) {
mVideoWriter.open(recordfilepath(), VideoWriter.fourcc('M', 'P', '4', '2'), 30.0D, mat.size());
}
Utils.bitmapToMat(bitmap, mat);
mVideoWriter.write(mat);
} else {
if (mVideoWriter != null) {
mVideoWriter.release();
mVideoWriter = null;
}
}
}