Hello Android video experts :)
I am developing an Android application which allows the user to capture video and upload it to a remote server (it's more involved than that but the rest of the app is not important). Because of the upload requirement, it is important that the video is of a reasonable size, so not super high resolution. Let's say a max of 680x480 or 10Mb/minute. This is no problem on Apple devices.
I have had what can only be described as a complete nightmare trying to capture video at a reasonably low bitrate reliably across a range of Android devices.
As I understand it there are two ways of capturing video on Android:
1) Using the Media Recorder/Camera API
2) Using an Intent to open the cameras video capture application
Option 1) gives the most flexibility and allows us to easily change the capture resolution. However the Android Camera API is NOT reliable across a range of devices, and I have very good information (including from someone who liaised with Google on this issue) that if you capture video using this API then it will crash on a good 50% of the devices out there. There is a reason that Zoom Camera FX uses an Intent for video capture. Zoom Camera (different app) seems to use Media Recorder, but has lots of bad reviews for video crashing or not working.
Option 2) works well across a range of devices, as it uses the in built application on the device. The trouble is you have no control whatsoever on the resolution, there is a quality hint on the Intent but the camera app will normally ignore this. My Samsung Galaxy S3 records video by default at about 2Mb/s. This is way too high resolution. The built in application can of course change the resolution, but this relies on action by the user which is difficult to control.
I understand that I could use a library such as ffmpeg to change the resolution of the video after capture. However this requires me to compile the library for Android, and also I have been informed that in order to legally use the decode/encode codecs on the device you have to pay license fees that amount to about $1 per copy of the app. Since this app will be free to use, this is not an option.
So that's where I'm at. I've searched long and high for answers, but I can't figure out how to capture low resolution video reliably using Android.
Any help very much appreciated!
Matthew
You can define exactly that in the MediaRecorder
class by setting Frame size (width x height)
, use method the setVideoSize(int width, int height)
, the smaller the frame size the smaller the video, this applies to all Android phones, you won't need to change frame size per device, or you could encode the bit rate, this controls compression quality of each frame. Use method setVideoEncodingBitRate (int bitRate)
the lower bit rate results in higher compression, which in turn leads to lower quality and lower video file size. Take a good look at the MediaRecorder
class.
If you target API 18 and up, you can use Camera
and MediaCodec
together to record at an arbitrary size and bit rate. See, for example, the "Show + capture camera" activity in Grafika.
You can check the platform version dashboard to estimate the size of the target market at a given API level.
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