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"
A screen recording, sometimes called a screencast or video screen capture, is a digital recording of rendered scenes (ideally 60 frames per second) on a computer screen, often containing audio narration as well as a webcam or facecam video of the narrator.
Download and Install Screen recorder – No Ads application from the Play Store. Open the app and give all the permissions. Now, tap on the Hamburger icon and select Settings from the menu. Head over to the Video Settings > Frame Rate and select the desired framerate.
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:
Hope that helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With