I want to make the app like "EASY screen recorder". From where I have to start because I search a lot but not any link i have found to getting start. There is any api that is used to create the screen recorder not screen shots. I do not want to create video from screen shots using javacv. I just want user start the application and and click on start recording button and what ever user did on the mobile record these.
1) Is there any api for this in android.
2) How I can create the screen recorder application in android.
3) Is there is not any api in android then please refer me other api so I can used in the android.
I search a lot but still no able to create the recording app.
I have android application in which i add the code that take the screen shots using the handler after specific time at the end it create the video using javacv but i do not like because for this i have to write the code in every application and that take the screen shots of current activity and at the end create the video.
How EASY screen recorder developer create this app? which api they used. I want to create the clone of this app.
Sorry for late answer but here is a working code. It will work on Lollipop
and above
private VirtualDisplay mVirtualDisplay;
private MediaRecorder mMediaRecorder;
private MediaProjection mMediaProjection;
private MediaProjectionCallback callback;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MediaProjectionManager projectionManager = (MediaProjectionManager)
context.getSystemService(Context.MEDIA_PROJECTION_SERVICE);
mMediaProjection.registerCallback(callback, null);
initRecorder();
mMediaRecorder.prepare();
mVirtualDisplay = createVirtualDisplay();
mMediaRecorder.start();
}
public void initRecorder() {
path = "/sdcard/Record/video" + ".mp4";
recId = "capture-" + System.currentTimeMillis() + ".mp4";
File myDirectory = new File(Environment.getExternalStorageDirectory(), "Record");
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mMediaRecorder.setVideoEncodingBitRate(MainFragment.bitRate);
mMediaRecorder.setVideoFrameRate(30);
mMediaRecorder.setVideoSize(MainFragment.DISPLAY_WIDTH,
MainFragment.DISPLAY_HEIGHT);
mMediaRecorder.setOutputFile(path);
}
private VirtualDisplay createVirtualDisplay() {
return mMediaProjection.createVirtualDisplay("MainActivity",
MainFragment.DISPLAY_WIDTH, MainFragment.DISPLAY_HEIGHT, MainFragment.screenDensity,
DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
mMediaRecorder.getSurface(), null /*Callbacks*/, null /*Handler*/);
}
public class MediaProjectionCallback extends MediaProjection.Callback {
@Override
public void onStop() {
mMediaRecorder.stop();
// mMediaRecorder.reset();
mMediaRecorder.release();
mMediaProjection.unregisterCallback(callback);
mMediaProjection = null;
mMediaRecorder = null;
}
As Per Android 5.0, you will be able to capture screen contents through MediaProjection API and you dont have to root the device.Try to project on SurfaceView and record from there.
there are few work arounds - which does not require you to root your device).
if you are creating a demo for your app, then you can use an emulator or bluestack and a desktop screen recorder to record just the emulator.
if you need to show the app in use on actual phone, then you can use another camera to record the app being used.
if you have to capture the screen and can hook the phone up to a computer, you can take screenshots of the phone screen from the desktop at a faster rate (doing the same as Dalvik Debug Monitor Device > Screen capture.), and then combine the images into a movie.
If you have to create an app, then you will have to explore the NDK.
Android doesn't provide any API exposing the frame buffers, you need to root your device and could use some source code from http://code.google.com/p/fastdroid-vnc/ for getting the raw frame buffer and then record it.
Remember, you need to root your device for doing this.
The simplest way using android kitkat is using ADB screenrecord command.