在“我的应用程序”中,我必须打开PDF和文档并在其上涂鸦并记录下来。录制后,由于质量差而看不到PDF和Docs的内容。这是我录制屏幕的代码。这里录制的视频大小不是问题。录制的视频质量很差。我需要为我的应用提供更好的质量。
currentPath = initRec();
mediaProjectionManager= (MediaProjectionManager)getSystemService(Context.MEDIA_PROJECTION_SERVICE);
startActivityForResult(mediaProjectionManager.createScreenCaptureIntent(),SCREEN_CAPTURE);
mediaRec.start();
private String initRec() {
mediaRec=new MediaRecorder();
mediaRec.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRec.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mediaRec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRec.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRec.setVideoEncodingBitRate(3000000);
mediaRec.setVideoFrameRate(16);
mediaRec.setVideoSize(480,640);
//CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
//mediaRec.setProfile(cpHigh);
String currentPath=getFilePath();
mediaRec.setOutputFile( currentPath);
try {
mediaRec.prepare();
} catch (IOException e) {
e.printStackTrace();
}
return currentPath;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode==SCREEN_CAPTURE)
{
mediaProjectionInstance=mediaProjectionManager.getMediaProjection(resultCode,data);
virtualDisp=createVirtualDisplay();
}
private VirtualDisplay createVirtualDisplay() {
DisplayMetrics displayMetrics=new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
// Surface surface=mediaRec.getSurface();
VirtualDisplay vd=mediaProjectionInstance.createVirtualDisplay("ABC",
480,640,
displayMetrics.densityDpi,
DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
mediaRec.getSurface(),null,null);
return vd;
}