Record entire screen, including front camera preview - android

I wrote a small game. It has a front facing cam preview implemented. I want to be able to record the entire screen to a mp4. How would I do that? Anyone know a nice tutorial for recording the entire screen to mp4 (in code, so not just screenshots.. I want to enable the user to make a recording, while playing the game).

Indeed, as #Michael stated, directly accessing the screenshot and framebuffer mechanisms is not possible. That doesn't mean you're completely out of luck, though, if you want to record gaming sessions. It's just more work.
If you generate a perfect record of the various actions in your game, save that record. You can then build a service (web service, local, whatever) that accepts the record as an input. In effect, it would replay the game. You'd then reconstruct the game in such a manner that you could generate a video.
You could also replay in the Android emulator and create a video from that. Not as easily deployable, but it depends on what you want to do with it.

Apps aren't allowed to grab the screen contents (see this discussion).
[L]etting applications grab the screen's content liberally is a serious security risk, which is why the platform prevents it (taking a snapshot requires either direct physical manipulation from the user, or using a debugging tool).
And as #CommonsWare mentioned in his comment you can't use the getDrawingCache method either to grab a Bitmap of the View if you're using a SurfaceView or one of its children (e.g. VideoView). More details about that here.

Related

Screen partial stream in Android

I'm developing an app that is like a whiteboard.
I'm able to mirror the screen through Chromecast, but this way the whole screen is streamed.
But I want that only a part of the screen be streamed, as I have the whiteboard itself and a toolbar that shouldn't be on the streaming.
Is it possible to choose what Views should be streamed on Android?
No. Streaming works via the video recording apps, it grabs the entire screen's data. At that level it doesn't even know views exist.
Yes, it is possible. You should use the Remote Display APIs from Cast SDK v2 where you specify what view/surface in your app should be mirrored on a cast device. It is a great match for what you want to do.

android make video of screen -need to take application video

In one of my application i need to record video of my own screen.
I need to make a video in that user can take video of their app how it possible?
first question is it possible so? if yes then how? any useful links or some help
Thanks
Pragna Bhatt
Yes, it is possible, but with certain limitations. I have done it in one of my projects.
Android 4.4 adds support for screen recording. See here
If you are targeting lower versions, you can achieve it, but it will be slow. There is no direct or easy way to do it. What you will do is, create drawable from your view/layout. Convert that drawable to YUV format and send it to camera (see some library where you can give custom yuv image to camera), camera will play it like a movies, you can save that movies to storage. Use threads to increase frame-rate (new multi-core device will have high frame-rate).
Only create drawable (from view) when there is any change in view or its children, for that you can use Global Layout Listener. Otherwise send same YUV image to camera.
Limitation:
You can not create video of more than one activities (at a time), or their transactions, because you are creating image from view. (Work on it yourself, may be you'll find a way)
You can not increase frame rate from a certain point, because it depends on hardware of your device.

Frame Video in Device Art from Android Studio Screen Record

In Android Studio we can both capture and record screen on our devices. When capturing the screen we have the option to directly frame our screenshot in device art or use online tool http://developer.android.com/distribute/tools/promote/device-art.html
When Recording Screen there is no option to frame it in device art and Google don't seem to provide any online option either.
What would be the fastest and easiest way for developers that want to showcase their screen recording in a frame from device art where a new video is created where device art is wrapped around our screen recording.
Give away your best tip. I would love a fast, free online service that solves this and guess there is one out there.
I've spent a substantial amount of time researching, but could also not find a service for it.
I have however written a guide for how to record screen, add device frame and convert to gif, which you can find here:
http://appdictive.dk/blog/how-to/2015/04/20/google_plus_gif/
The short version of it is:
Record screen
Get Device frame picture
Use Photoshop or other video editing software to add the frame as static picture to the video (guide briefly shows how to do this in Photoshop).
Hope this helps others searching for a solution to this as well.
There are very few services I've come across on the web that allow you to simply upload a video within device art frames, especially free platforms. However, if you have video editing software such as Adobe After Effects, you could import images and videos and create this yourself; albeit added cost and time against the earlier option.
Despite the above, I've managed to utilise Google's Device Art Generator page to extract the device frames they offer quite easily. All you need to do is create a solid background colour in Adobe Photoshop (as an example), say bright green, followed by uploading this to the generator. Download the image generated with the device art applied with the solid fill colour and then use the Magic Wand tool in Photoshop and simply delete the solid colour. With this in mind, the next course of action is to simply insert the video using After Effects in the transparent space now available. This is even a bit overkill, as you only need to overlay the video within the screen dimensions of the generated screenshot from Google, yet this gives you an idea of how you could achieve what you want.
I had the same problem and ended up writing an app to do that:
https://play.google.com/store/apps/details?id=de.mobilej.recapp
It works completely on the device - no plugin or desktop version yet. It needs Android 7.0+
I'm the author of the app - so sorry for referring to my own app.

In-App screen recording on android to capture 15 frames per second

After a lot of searching and days of experiments I haven't found a straight-forward solution.
I'm developing an app that user will interact with a pet on the screen and i want to let him save it as video.
Is there any "simple" way to capture the screen of the app itself?
I found a workaround (to save some bitmaps every second and then pass them to an encoder) but it seems too heavy. I will happy even with a framerate of 15fps
It seems to be possible, i.e. there is a similar app that does this, its called "Talking Tom"
It really depends on the way you implement your "pet view". Are you drawing on a Canvas? OpenGl ES? Normal Android view hierarchy?
Anyway, there is no magical "recordScreenToVideo()" like one of the comments said.
You need to:
Obtain bitmaps representing your "frames".
This depends on how you implement your view. If you draw yourself (Canvas or OpenGL), then save your raw pixel buffers as frames.
If you use the normal view hierarchy, subclass Android's onDraw and save the "frames" that you get on the canvas. The frequency of the system's call to onDraw will be no less than the actual "framerate" of the screen. If needed, duplicate frames afterwards to supply a 15fps video.
Encode your frames. Seems like you already have a mechanism to do that, you just need it to be more efficient.
Ways you can optimize encoding:
Cache your bitmaps (frames) and encode afterwards. This will work
only if your expected video will be relatively short, otherwise
you'll get out of storage.
Record only at the framerate that your app actually generates (depending on the way you draw) and use an encoder parameter to generate a 15fps video (without actually supplying 15 frames per second).
Adjust quality settings to current device. Can be done by performing a hidden CPU cycle test on app startup and defining some thresholds.
Encode only the most relevant portion of the screen.
Again, really depending on the way you implement - if you can save some "history data", and then convert that to frames without having to do it in real time, that would be best.
For example, "move", "smile", "change color" - or whatever your business logic is, since you didn't elaborate on that. Your "generate movie" function will animate this history data as a frame sequence (without drawing to the screen) and then encode.
Hope that helps

Video camera auto focus

I developed a small video camera application. It all works fine except focus.
I understand I need to call camera.autofocus, but I don't really know where is the right place to put the call it.
Anyone ever succeeded in autofocusing a video camera on android?
Thank
Eli
It's probably a matter of preference based on how you think users will use your app.
I think a common convention is to do an auto-focus when the user touches the scene in the preview. Most OEM camera apps seem to do this.
Doing auto-focus after zooming is also a common thing.
Finally, you might want to have a look at the zxing project (bar code scanner app) which has a nifty continuous auto focus approach that might be of use, though since youre capturing video, it might not be ideal as the focus transitions might be too noticeable.
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/camera/AutoFocusCallback.java?r=1698

Categories

Resources