How to capture the screen as fast as possible through adb?
How to capture the screen as fast as possible through adb?
Recently, I wrote a PC client which can display and control my android phone screen in real-time using adb. I use the monkey to control the device and it works fine. The problem is how to grab the phone screen and display it smoothly.
The first solution I have come up with is to continually grab the framebuffer
through adb
(like DDMS's screen capture function). Now when I do it, the performance is quite unacceptable. The frame rate captured from framebuffer
is as low as 5 per second (the frame size is 800 * 480). My program looks like its hiccuping when I slide on the phone.
My program is written in java using ddmslib
to grab framebuffer
.
add:
I found it much slow to encoding the raw framebuffer
data into .png
format, otherwise this will be a fast way to transmit a compress raw image.
How can I improve the speed of capturing the screen to a smooth level?
Answer by Diego Torres Milano for How to capture the screen as fast as possible through adb?
You could use:
$ adb shell screencap -p > sc.png
which unfortunately doesn't work (file is corrupted), so your option left is
$ adb shell screencap -p /mnt/sdcard/sc.png $ adb pull /mnt/sdcard/sc.png
while this is relatively fast, it's probably not as fast as you need.
Answer by steveha for How to capture the screen as fast as possible through adb?
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
Source:
http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html
Answer by Ram Vijapurapu for How to capture the screen as fast as possible through adb?
I have improved on @steveha's solution:
Create a shell script say: 'android-screenshot' with the following contents:
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen-`date +%Y-%m-%d_%X`.png
Place this file in your local bin directory or any other $PATH you prefer.
This would allow you to save the files with a timestamp in the current directory.
Remember to make the shell script executable using
chmod +x android-screenshot
Answer by S P Arif Sahari Wibowo for How to capture the screen as fast as possible through adb?
Well some people said in Perl there is many ways to do one thing. :-) Anyway, this one may perform better (since there is no regular expression), and may resolve the issue in Cygwin in MS Windows (whose Perl define \n
as CRLF):
adb shell screencap -p | perl -pe 'BEGIN { $/="\cM\cJ"; $\="\cJ"; } chomp;' > screen-$(date +%Y%m%d_%H%M%S).png
Answer by William Jockusch for How to capture the screen as fast as possible through adb?
In .bash_profile on my mac:
function droidShot() { /full_path_to_droid_sdk/platform-tools/adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > $1.png }
usage:
droidshot whatever
and the file shows up in whatever.png
Answer by Grant Peters for How to capture the screen as fast as possible through adb?
Using this method, my app continues to run at it's full framerate
adb pull /dev/graphics/fb0
This will pull down the raw data from the frame buffer. It seems to be the same width as the screen, but the height is padded out. The frame buffer on my device seems to be in RGBA8888 format. To get exactly what is displayed on screen, you should ignore the alpha channel.
Note that this does take ~0.8 seconds to download for me (resoultion: 480x854) but if i have it downloading on a continuous loop, it doesn't affect the device's frame rate.
Answer by Pyro for How to capture the screen as fast as possible through adb?
if the slow part is raw to png conversion (time adb shell screencap -p /sdcard/x.png
is considerably slower than time adb shell screencap /sdcard/nonpng.raw
, as I have it in games) and png is not necessary, then you can do like here https://github.com/sowcow/shot. It converts raw data to simple ppm format and converts ppm to bmp using imagemagick with almost no overhead after it gets raw data
upd:
This shell script by max_plenert is a better example:
adb shell screencap /sdcard/mytmp/rock.raw adb pull /sdcard/mytmp/rock.raw adb shell rm /sdcard/mytmp/rock.raw // remove the header tail -c +13 rock.raw > rock.rgba // extract width height and pixelformat: hexdump -e '/4 "%d"' -s 0 -n 4 rock.raw hexdump -e '/4 "%d"' -s 4 -n 4 rock.raw hexdump -e '/4 "%d"' -s 8 -n 4 rock.raw convert -size 480x800 -depth 8 rock.rgba rock.png
Answer by Joseph Lennox for How to capture the screen as fast as possible through adb?
There is a screenrecord
program as of Android 4.4
adb shell screenrecord /data/local/tmp/test-video.m4v adb pull /data/local/tmp/test-video.m4v ~/test-video.m4v
Answer by Manoj Behera for How to capture the screen as fast as possible through adb?
adb shell screenrecord --bit-rate 8000000 --time-limit 30 /sdcard/example.mp4
You can change the bit rate and change the video duration also.
Answer by Sergey Shustikov for How to capture the screen as fast as possible through adb?
From docs :
Taking a device screenshot
The screencap command is a shell utility for taking a screenshot of a device display. While in a shell, the syntax is:
screencap
To use the screencap from the command line, type the following:
$ adb shell screencap /sdcard/screen.png
Here's an example screenshot session, using the adb shell to capture the screenshot and the pull command to download the file from the device:
$ adb shell shell@ $ screencap /sdcard/screen.png shell@ $ exit $ adb pull /sdcard/screen.png
Recording a device screen
The screenrecord command is a shell utility for recording the display of devices running Android 4.4 (API level 19) and higher. The utility records screen activity to an MPEG-4 file.
Note: Audio is not recorded with the video file.
A developer can use this file to create promotional or training videos. While in a shell, the syntax is:
screenrecord [options]
To use screenrecord from the command line, type the following:
$ adb shell screenrecord /sdcard/demo.mp4
Stop the screen recording by pressing Ctrl-C, otherwise the recording stops automatically at three minutes or the time limit set by --time-limit.
To begin recording your device screen, run the screenrecord command to record the video. Then, run the pull command to download the video from the device to the host computer. Here's an example recording session:
$ adb shell shell@ $ screenrecord --verbose /sdcard/demo.mp4 (press Ctrl-C to stop) shell@ $ exit $ adb pull /sdcard/demo.mp4
The screenrecord utility can record at any supported resolution and bit rate you request, while retaining the aspect ratio of the device display. The utility records at the native display resolution and orientation by default, with a maximum length of three minutes.
There are some known limitations of the screenrecord utility that you should be aware of when using it:
Some devices may not be able to record at their native display resolution. If you encounter problems with screen recording, try using a lower screen resolution. Rotation of the screen during recording is not supported. If the screen does rotate during recording, some of the screen is cut off in the recording.
Answer by christian for How to capture the screen as fast as possible through adb?
This a slow solution, i am sure it is the faster way you may find in adb based solutions,
# this line require a superuser privilege: adb shell "su -c 'cat /dev/graphics/fb0 > /sdcard/capture.raw'" adb pull /sdcard/capture.raw ffmpeg -loglevel panic -f rawvideo -pix_fmt bgr32 -s 320x480 -i \ capture.raw -vcodec png -vframes 1 capture.png;
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
0 comments:
Post a Comment