What I am trying to achieve is recording video via my android device and sending it live to a server for real time video chat.
The server side isn't an issue, I have just not been able to find anyway to encode live video from the camera and output this data to the server via a socket (or any other way).
I have been banging my head against the wall for days and do not seem to be getting anywhere. MediaRecorder has given me no hope, it crashes without any helpful errors most of the time and is unable to write to a ParcelFileDescriptor.fromDatagramSocket().
The closest I have gotten to what I am trying to achieve is only displaying the camera in a preview on screen. Eg.
val cameraProviderFuture = ProcessCameraProvider.getInstance(this)
cameraProviderFuture.addListener(Runnable {
val cameraProvider = cameraProviderFuture.get()
val preview = Preview.Builder().build()
val myPreviewView: PreviewView = findViewById(R.id.myPreviewView)
preview.setSurfaceProvider(myPreviewView.surfaceProvider)
val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
cameraProvider.bindToLifecycle(this, cameraSelector, preview)
}, ContextCompat.getMainExecutor(this))
Currently using API level 29 and it would be great if this can be done via camera2/camerax.
My experience is in backend using Python so please forgive any ignorance. Help would be greatly appreciated.
Thanks