Android Things: take a screenshot

和自甴很熟 提交于 2019-12-23 09:34:09

问题


How do you take a screenshot via ADB for Android Things? I have tried:

adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png
adb shell rm /sdcard/screen.png

and

adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png

回答1:


I couldn't make screepcap work in Android Things Developer Preview. The command results in a 0-size file.

That said, I recommend the following two options: either use the framebuffer or record a video (screenrecord seems to work) and convert it to an image later on by proper tool. I'll consider the first option, so the steps would be:

  • Pull the framebuffer to the host machine. Note that you need to start adbd as root in order to pass a permission check:

    adb root
    adb pull /dev/graphics/fb0 screenshot
    
  • Convert the raw binary to image by the tool you prefer. I'm using ffmpeg. The command below might not work for you due to different screen resolution or pixel format. If so, make proper changes.

    ffmpeg -f rawvideo -pix_fmt rgb565 -s 800x480 -i screenshot screenshot.png
    



回答2:


Seems, because of old limited OpenGL version in Android Things, described by Tatsuhiko Arai here there is no possibility to get screenshot via ADB, but You can record video (e.g. from Android Studio, or via ADB commands) and than grab frame from it, for example via ffmpeg:

ffmpeg -i device-2017-01-23-193539.mp4 -r 1 screen-%04d.png

where device-2017-01-23-193539.mp4 - name of recorded (via Android Studio) file .



来源:https://stackoverflow.com/questions/41534666/android-things-take-a-screenshot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!