[android] Capture Video of Android's Screen

Forget screenshots, is it posible to capture a video of the running application in android? Rooted or non-rooted, I don't care, I want atleast 15fps.

Update: I don't want any external hardware. The intent is to make it perfectly portable and every frame is captured within Android OS. If it crosses the boundaries of the app sdk, I'm willing to go to OS level modifications but I would need a starting point.

This question is related to android video-capture

The answer is


In Android Lollipop (5) a new feature has been added which allows screen capture which is explained here

Here is an example

Call startActivityForResult like this

startActivityForResult(mProjectionManager.getScreenCaptureIntent(), PERMISSION_CODE);

Then capture the result

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode != PERMISSION_CODE) {
        Log.e(TAG, "Unknown request code: " + requestCode);
        return;
    }
    if (resultCode != RESULT_OK) {
        Toast.makeText(this,
                "User denied screen sharing permission", Toast.LENGTH_SHORT).show();
        return;
    }
    mMediaProjection = mProjectionManager.getMediaProjection(resultCode, data);
    mVirtualDisplay = createVirtualDisplay();
}

This is old, but what about ASC?


If you are on a PC then you can run My Phone Explorer on the PC, the MyPhoneExplorer Client on the phone, set the screen capture to refresh continuously, and use Wink to capture a custom rectangular area of your screen over the My Phone Explorer window with your own capture rate. Then convert to a FLV in Wink, then convert from Flash video to MPG with WinFF.


I know this is an old question but since it appears to be unanswered to the OPs liking. There is an app that accopmlishes this in the Android Market Screencast link


If you developing video-camera applications, then it will be good to know the API to use for video capturing:

http://developer.android.com/training/camera/videobasics.html

(the above link only show how the video recording can be done via Intent submission, not how the actual recording is done)

https://www.linux.com/learn/tutorials/729988-android-app-development-how-to-capture-video

and if you want to write the "screenrecord" adb application yourself:

https://android.googlesource.com/platform/frameworks/av/+/android-cts-4.4_r1/cmds/screenrecord/screenrecord.cpp

And the key recording action is done here:

static status_t recordScreen(const char* fileName) {
    status_t err;

<...>

    // Configure, but do not start, muxer.
    sp<MediaMuxer> muxer = new MediaMuxer(fileName,
            MediaMuxer::OUTPUT_FORMAT_MPEG_4);
    if (gRotate) {
        muxer->setOrientationHint(90);
    }

    // Main encoder loop.
    err = runEncoder(encoder, muxer);
    if (err != NO_ERROR) {
        encoder->release();
        encoder.clear();

        return err;
    }

For Samsung phone there is additional settings ('cam_mode' hack):

CamcorderProfile.QUALITY_HIGH resolution produces green flickering video

More useful links:

How can I capture a video recording on Android?


@taranfx, without more info I'm assuming since you are on StackOverFlow that you have the Android Developer Tools installed. If so you can run the emulator and then use one of the many desktop screen capture programs to capture your running application. Screenflow on the Mac works great for doing this. I am sure there are many good screen capture programs if you are on Windows or a Nix platform and I know there are some online services as well but I do not have any links nor have I used them. Here is a link for the reference document on setting up and running the emulator.The Android SDK includes a mobile device emulator...


If you want to record the user navigation so you can test UI and other things, I recommend you to use TestFairy

It allows you to send the apk to some test users by email and see a video with all the sessions in the app and even the app crashes and device stats.


AirPlay Mirroring and Screen Recording is now in CyanogenMod with Mirror APK (Beta).


I have not used the app, but I've seen Rec. referenced as a way to do this, but you need root the phone.


Android 4.3 has a new MediaCodec API that can be used to record from a surface. See: http://developer.android.com/about/versions/android-4.3.html (scroll down to the section "Video encoding from a Surface")


Yes, use a phone with a video out, and use a video recorder to capture the stream

See this article http://graphics-geek.blogspot.com/2011/02/recording-animations-via-hdmi.html


It is possible to record screen video directly from your phone or tablet if your device is rooted. I'm working on the SCR Screen Recorder app. To the best of my knowledge this is the only app supporting Tegra devices (including Nexus 7) and Android 4.2. At the moment the app records between 9-18fps depending on device but I'm working to improve that. SCR Screen Recorder is still in beta testing phase so feel free to test it and give feedback.


Take a look at Remote Manager. But seems to me it doesn't work correctly with devices which have big screen. Although, you can try DEMO before.


I didn't implement it but still i am giving you an idea to do this.

First of all get the code to take a screenshot of Android device. And Call the same function for creating Images after an interval of times. Add then find the code to create video from frames/images.

Edit

see this link also and modify it according to your screen dimension .The main thing is to divide your work into several small tasks and then combine it as your need.

FFMPEG is the best way to do this. but once i have tried but it is a very long procedure. First you have to download cygwin and Native C++ library and lot of stuff and connect then you are able to work on FFMPEG (it is built in C++).


My suggestion is also to use a screen recorder, such as SMRecorder. Instead of using the emulator, which is slow - especially for games and things you would want a video of, I recommend using a VirtualBox VM, with Android installed. You can connect the Dalvik debugger to it and debug you app there. If the debugger slows down you app too much, disconnect it to record the video. There are many links out there explaining how to set up the Android VM for debugging. I find it far better than the emulator. Now this does not take care of capturing screens directly on the device, in case you app uses the accelerometer, or the camera that are not available on the PC. For that I would use the android market app mentioned above.


I guess screencast is no go cause of tegra 2 incompatibility, i already tried it,but no whey! So i tried using Z-ScreeNRecorder from market,installed it on my LG Optimus 2x, but it record's only blank screen,i tried for 5min. and there i get 5min. of blank screen file of 6mb size... so there is no point trying until they release some peace of software that is compatible with tegra2 chipset!