以下是部分代码
public void setRecorder()
{
String time = new SimpleDateFormat("yyyyMMddHHmmss",
Locale.getDefault())
.format(new Date(System.currentTimeMillis()));
recorder = new FFmpegFrameRecorder(videoPath
+ File.separator + time+".mp4", screenWidth, screenHeight);
recorder.setFormat("mp4");
recorder.setFrameRate(9f);
try {
recorder.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void saveVideo(Bitmap frame) {
try {
if (isVideo) {
if (!image2VideoFile.exists()) {
image2VideoFile.createNewFile();
}
os = new FileOutputStream(image2VideoFile);
frame.compress(Bitmap.CompressFormat.JPEG, 100, os);
os.flush();
os.close();
opencv_core.IplImage image = cvLoadImage(videoPath+ File.separator + "video.jpg");
recorder.record(image);
if (index + 1 > INDEX_MAX) {
index = 1;
} else {
index++;
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
然后错误
public void setRecorder()
{
String time = new SimpleDateFormat("yyyyMMddHHmmss",
Locale.getDefault())
.format(new Date(System.currentTimeMillis()));
recorder = new FFmpegFrameRecorder(videoPath
+ File.separator + time+".mp4", screenWidth, screenHeight);
recorder.setFormat("mp4");
recorder.setFrameRate(9f);
try {
recorder.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void saveVideo(Bitmap frame) {
try {
if (isVideo) {
if (!image2VideoFile.exists()) {
image2VideoFile.createNewFile();
}
os = new FileOutputStream(image2VideoFile);
frame.compress(Bitmap.CompressFormat.JPEG, 100, os);
os.flush();
os.close();
opencv_core.IplImage image = cvLoadImage(videoPath+ File.separator + "video.jpg");
recorder.record(image);
if (index + 1 > INDEX_MAX) {
index = 1;
} else {
index++;
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
然后错误
![](http://img.bbs.csdn.net/upload/201601/19/1453213657_94121.png)