java 捕获android屏幕并以编程方式创建视频
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13424149/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Capture android screen and create video programmatically
提问by androidqq6
In Android/Java, Is there any code example to capture the screenshot of a computer with good frames per second programatically and create video?
在 Android/Java 中,是否有任何代码示例可以以编程方式以每秒良好的帧数捕获计算机的屏幕截图并创建视频?
I'd like a tutorial or full source code to do this. I'd like the program to work with and without the device having been "rooted".
我想要一个教程或完整的源代码来做到这一点。我希望该程序可以在设备“植根”和不“植根”的情况下运行。
There is app in the play store called Screencast Video Recorder
that does this. But you need to ROOT the device for it to work, so I know it can be done.
Play 商店中有一个应用程序Screencast Video Recorder
可以执行此操作。但是你需要ROOT设备才能工作,所以我知道它可以做到。
What's the best way to capture android screenshot and create a video programmatically on a non-rooted device?
在非root设备上以编程方式捕获android屏幕截图并创建视频的最佳方法是什么?
回答by Neeraj Sharma
Check the following link https://code.google.com/p/java-remote-control/
检查以下链接 https://code.google.com/p/java-remote-control/
in this project the owner has created a java remote control i.e. he has captured the images from the remote computer and transfer to server and convert it to movies with different format all you need to understand what he has done and implement the same for all your needs. you can access the full source code with SVN client from the following URL
在这个项目中,所有者创建了一个 java 遥控器,即他从远程计算机捕获图像并将其传输到服务器并将其转换为不同格式的电影,您需要了解他所做的一切,并为您的所有需求实现相同的功能. 您可以从以下 URL 使用 SVN 客户端访问完整的源代码
http://java-remote-control.googlecode.com/svn/trunk/
http://java-remote-control.googlecode.com/svn/trunk/
Also you can look for the Remote class in java which provides createScreenCapture method
您也可以在提供 createScreenCapture 方法的 java 中查找 Remote 类
回答by zmarties
As of Android 4.4, there is a screen recording feature accessible via adb.
从 Android 4.4 开始,可以通过 adb 访问屏幕录制功能。
http://developer.android.com/tools/help/adb.html#screenrecord
http://developer.android.com/tools/help/adb.html#screenrecord
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, which you can then download and use as part of a video presentation. This utility is useful for developers who want to create promotional or training videos without using a separate recording device.
screenrecord 命令是一个 shell 实用程序,用于记录运行 Android 4.4(API 级别 19)及更高版本的设备的显示。该实用程序将屏幕活动记录到 MPEG-4 文件中,然后您可以下载该文件并将其用作视频演示的一部分。此实用程序对于想要在不使用单独的录制设备的情况下创建宣传或培训视频的开发人员非常有用。
回答by ucsunil
There is an app called Telecine that is open source that allows you to record screens - the code can be found at https://github.com/JakeWharton/Telecine. All credit is to Jake Wharton.
有一个名为 Telecine 的开源应用程序,它允许您录制屏幕 - 代码可以在https://github.com/JakeWharton/Telecine找到。所有的功劳都归功于Hyman沃顿。
If you need an example, you can find one at Commonsware's github page - Mark Murphy has provided a sample app for both screen capture and screen recording using the MediaProjection APIs.
如果您需要一个示例,您可以在 Commonsware 的 github 页面上找到一个示例 - Mark Murphy 提供了一个示例应用程序,用于使用 MediaProjection API 进行屏幕捕获和屏幕录制。
回答by Android Stack
you can capture the screen via using DDMS as adb runs and has permission to the framebuffer:
您可以在 adb 运行时使用 DDMS 捕获屏幕,并且对帧缓冲区具有权限:
follow this link for more details :
点击此链接了解更多详情:
ALSO
还
check this links may be get some ideas about what you need :
检查这个链接可能会得到一些关于你需要什么的想法:
http://answers.oreilly.com/topic/951-how-to-capture-video-of-the-screen-on-android/
http://answers.oreilly.com/topic/951-how-to-capture-video-of-the-screen-on-android/
and check this project :
并检查这个项目:
http://sourceforge.net/projects/ashot/
http://sourceforge.net/projects/ashot/
hope this help .
希望这有帮助。
回答by Robert Estivill
Try this application from the market
试试这个市场上的应用程序
https://play.google.com/store/apps/details?id=com.ms.screencastfree
https://play.google.com/store/apps/details?id=com.ms.screencastfree
** Does not work on Galaxy Nexus or Tegra 2/3 yet **
** 不适用于 Galaxy Nexus 或 Tegra 2/3 **
EDIT 28/11/2014
编辑 28/11/2014
Lollipop has been released and provides a new Screen recording API
Lollipop 已发布并提供新的屏幕录制 API
http://developer.android.com/about/versions/android-5.0.html#UI
http://developer.android.com/about/versions/android-5.0.html#UI
Screen capturing and sharing
Android 5.0 lets you add screen capturing and screen sharing capabilities to your app with the new android.media.projection APIs. This functionality is useful, for example, if you want to enable screen sharing in a video conferencing app.
The new createVirtualDisplay() method allows your app to capture the contents of the main screen (the default display) into a Surface object, which your app can then send across the network. The API only allows capturing non-secure screen content, and not system audio. To begin screen capturing, your app must first request the user's permission by launching a screen capture dialog using an Intent obtained through the createScreenCaptureIntent() method.
For an example of how to use the new APIs, see the MediaProjectionDemo class in the sample project.
屏幕捕获和共享
Android 5.0 允许您使用新的 android.media.projection API 向您的应用程序添加屏幕捕获和屏幕共享功能。此功能很有用,例如,如果您想在视频会议应用程序中启用屏幕共享。
新的 createVirtualDisplay() 方法允许您的应用程序将主屏幕(默认显示)的内容捕获到 Surface 对象中,然后您的应用程序可以通过网络发送该对象。API 仅允许捕获非安全屏幕内容,而不允许捕获系统音频。要开始屏幕捕获,您的应用程序必须首先使用通过 createScreenCaptureIntent() 方法获取的 Intent 启动屏幕捕获对话框来请求用户的许可。
有关如何使用新 API 的示例,请参阅示例项目中的 MediaProjectionDemo 类。