195

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.

Taranfx
  • 10,361
  • 17
  • 77
  • 95
  • I completely see what is being said here. It seems like the emulator should have the feature to redirect the current screen into a video file as well. I would love a feature like this so that I could make informative videos of my games and apps. – Robert Massaioli May 27 '11 at 03:57
  • 1
    Did u got solution for this? if so please share with us. i too have to caputre video of android screen. – deepa Jul 19 '11 at 07:59
  • @deepa nope there's no good way of doing this. – Taranfx Jul 22 '11 at 00:29
  • Is it possible to read from the hardware screen buffer ? – mP. Dec 02 '11 at 08:55
  • Check this project: http://sourceforge.net/projects/ashot/ – Nirmal Patel Aug 01 '11 at 19:27
  • This application effectively automates making screenshots. Recording from my LG Optimus 2X (running CyanogenMod 7.1), attached to a quad core machine, it ran at a miserable 0.6 fps. Also it takes some tinkering to get working, as it is not up to date with the latest Android SDK. [See the notes on the developer's blog.](http://www.mightypocket.com/2010/09/installing-android-screenshots-screen-capture-screen-cast-for-windows/) – Paul Lammertsma Dec 21 '11 at 11:18
  • Doesn't record video. – RajV Jan 31 '13 at 20:29
  • This is no good. It's too old. It has not even been updated for the new location of adb in platform-tools/. `05:17:22 E/adb: Failed to get the adb version: Cannot run program "/Users/fakelove/Downloads/adt-bundle-mac-x86_64-20130729/sdk/tools/adb": error=2, No such file or directory`. – Chloe Sep 10 '13 at 21:22
  • Use `ln -s ../platform-tools/adb adb` – Chloe Sep 10 '13 at 21:38
  • It only take png screenshots. You have to use FFMPEG or Adobe After Effects to turn them into a video. – Chloe Sep 11 '13 at 14:51

17 Answers17

245

Android 4.4 (KitKat) and higher devices have a shell utility for recording the Android device screen. Connect a device in developer/debug mode running KitKat with the adb utility over USB and then type the following:

adb shell screenrecord /sdcard/movie.mp4
(Press Ctrl-C to stop)
adb pull /sdcard/movie.mp4

Screen recording is limited to a maximum of 3 minutes.

Reference: https://developer.android.com/studio/command-line/adb.html#screenrecord

Joe Fernandez
  • 4,781
  • 4
  • 26
  • 23
  • is giving me response like screenrecord: not found adb is out dated why? – Poison Jan 29 '14 at 09:25
  • 1
    Sounds like your Android SDK is out of date. Open up Android SDK Manager and download the latest SDK tools. – Joe Fernandez Jan 30 '14 at 03:53
  • Is it possible to extend the recording time? – Stupid.Fat.Cat Jun 02 '14 at 03:48
  • 1
    Shame there is no audio with this. But awesome nonetheless. – Martin Capodici Jun 14 '14 at 11:20
  • This is awesome. I am getting some pretty bad artifacts on my `nexus 4` though. I tried upping the `bit-rate` to `6Mbps`. – theblang Jul 08 '14 at 20:22
  • 1
    Just to add, this page has a package having a standalone adb + script "ScreenRecord.bat" which can be double clicked to start recording android screen video.. http://www.skipser.com/p/2/p/record-screen-video-in-android.html – arunskrish Jul 23 '14 at 07:19
  • You can extend the recording time using `--time-limit`, followed by the number of seconds you want to record. [Reference here.](http://developer.android.com/tools/help/adb.html#screenrecord) – sulai Jul 28 '14 at 16:08
  • 1
    I get the error WARNING: linker: libsac3d.so has text relocations. This is wasting memory and is a security risk. Please fix. ERROR: unable to configure codec (err=-2147483648) WARNING: failed at 1080x1920, retrying at 720x1280 – Pete_ch Dec 01 '14 at 05:18
  • @sulai The max is still 3 minutes: "The default and maximum value is 180 (3 minutes)." – Joshua Pinter Feb 23 '15 at 18:59
  • Any backports for pre 4.4? – Xiao Jun 04 '15 at 00:09
  • And FYI you can show a dot at the location where you tap on the screen with an option in the developer options on the phone. – Adam Johns Dec 04 '15 at 23:11
  • Side note: this DOES NOT work on emulators! There is no mention of this limitation in the docs. It was divulged by the Google team here: https://code.google.com/p/android/issues/detail?id=61682 – Sean Beach Feb 05 '16 at 22:02
  • You can specify bitrate as "adb shell screenrecord --bit-rate 6000000 /sdcard/demo.mp4" – 水清木华 Aug 09 '16 at 06:28
  • Use bit rate, time limit & size options to change the quality of video "adb shell screenrecord --bit-rate 2000000 --time-limit 30 --size 1280×720" – Lava Sangeetham Apr 08 '18 at 06:13
  • If you want more than 3 minutes, just use `scrcpy`’s recording functionality. It has no limits. And even works over wifi, if set up over usb. It’s fast because it uses adb too. – Evi1M4chine Jul 15 '23 at 14:54
17

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

Zaphoid
  • 279
  • 2
  • 3
8

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

Ollie C
  • 28,313
  • 34
  • 134
  • 217
  • That's what I could have done but my requirement is to do everything inside android. Making it work on the go is the intent. – Taranfx Mar 22 '11 at 05:20
  • 1
    I think you're out of luck - the requirements to handle that much video encoding, on the fly, on a mobile device, is outside the scope of what most are physically capable of, Android (AFAIK) has no interface to access a stream, and even if it did, it's a potentially enormous security hole as an app could spy on the user. – Ollie C Mar 22 '11 at 10:57
4

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.

jdbertron
  • 733
  • 7
  • 11
4

@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...

MWR
  • 170
  • 8
3

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!

Mike Mackintosh
  • 13,917
  • 6
  • 60
  • 87
Nenad
  • 39
  • 1
2

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")

1

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.

Iwo Banas
  • 892
  • 8
  • 12
1

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.

Nolesh
  • 6,848
  • 12
  • 75
  • 112
1

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

Oli
  • 1,407
  • 3
  • 30
  • 47
1

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?

Community
  • 1
  • 1
Peter Teoh
  • 6,337
  • 4
  • 42
  • 58
1

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++).

Community
  • 1
  • 1
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
  • I did same as you suggested from taking images after an interval of time or without no interval, I have scrolling view in which i am doing scrolling and in another thread i am capturing screen area, but a same capturing is returns for 6-7 images and than another different area is captured. I need complete sequence of images. – Farrakh Javed Sep 19 '14 at 11:34
1

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.

red_alert
  • 1,738
  • 14
  • 24
1

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();
}
rogermushroom
  • 5,486
  • 4
  • 42
  • 68
0

This is old, but what about ASC?

Richard Cotrina
  • 2,525
  • 1
  • 23
  • 23
  • Due to incompatibility with Tegra-powered devices? .. yeah.. i got a Asus Transformer :C – Richard Cotrina Apr 28 '13 at 00:14
  • It requires running an 'activator' on the PC/Mac, but is unsigned and doesn't explain what it does nor how to do the 'activation' manually. It sounds like a security risk and threat vector. – Chloe Sep 10 '13 at 21:08
0

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.

Chloe
  • 25,162
  • 40
  • 190
  • 357
0

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

Rich Elswick
  • 561
  • 5
  • 20