Trying to capture a video and save it to sd card in Mp4/3gp formats using local socket. Being able to write bytes by bytes to sd card but the video file is not playable.I have gone through many examples :
https://github.com/fyhertz/spydroid-ipcamera
https://github.com/mconf/sipdroid
and many more. I have noticed people suggesting this might be a problem of file's header. I tried to skip those "mdat" data too from header:
private void skipHeader() throws IOException { // Skip all atoms preceding mdat atom byte[] buffer = new byte[3]; while (true) { while (mReceiver.getInputStream().read() != 'm'); mReceiver.getInputStream().read(buffer,0,3); if (buffer[0] == 'd' && buffer[1] == 'a' && buffer[2] == 't') break; } }
At last nothing worked for me.What extra do I need to do for making those video files playable using Local Socket
From your explanation, what you have in mind to implement is a screen recorder. Of course your intention is that the system will have it implemented as part of the technology that your software is offering.
In such case, the best approach is to improve what already exist, incorporating the code with new features or new performance and giving credit to the original source that you came across and included as part of your software - as expected. This is the beauty of Open Source, which allows code to be reused, distributed and improved.
At Github there are plenty of projects... as you know, some nice and others awesome. For your particular case, my suggestion is to use existing code that allows your streaming recording system to capture the video, writing it without any need to root the device, as final users would not be interested to void the warranty of a newly purchased device only to run your software.
It is also important to achieve a good speed that allows at least capturing 20 screen per second in Android for different screen sizes, providing clearly resolution and low CPU usage. All these characteristics would keep your solution stable and still looking rock solid.
I think the best approach you can take, that will save yourself time and lots of headaches, would be to incorporate the "sji-android-screen-capture" code as part of your project. If your target devices are Android 4.2~4.4, you are good to go as it supports these Android versions. More info and the source code itself, you find available at Github repository. Alternatively, you can also use Android ScreenCapture Sample to capture device screen in real time.
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