Hi, I use this solution as basic for video recording in music online teaching. It works very good, thanks to this super example. Student videos and tutor comments can be uploaded and downloaded from a server.
Only one problem: The audio latency. The sound is about one second later then the video and this is much for music teaching. By myself I only found ways to change video solution. May be, this code gives a hint?
B4X:
Public Sub Initialize (CameraPanel As Panel)
mPanel = CameraPanel
Camera.Initialize("Camera")
jcamera = Camera
PreviewSize.Initialize(1920, 1080)
CaptureSize.Initialize(1920, 1080)
StaticCaptureRequest.InitializeStatic("android.hardware.camera2.CaptureRequest")
StaticCameraCharacteristics.InitializeStatic("android.hardware.camera2.CameraCharacteristics")
StaticCaptureResult.InitializeStatic("android.hardware.camera2.CaptureResult")
PreviewSettingsMap.Initialize
CaptureSettingMap.Initialize
bothMaps = Array(PreviewSettingsMap, CaptureSettingMap)
End Sub
I am lost in this android hardware settings. Could someone, please, help?
This is indeed very strange. I use for Android the mentioned Camera2 / CamEx2 solution for recording, SimpleExoPlayer for playing. For iOS I use this LLCamera with Audio for recording and this VideoPlayer for playing.
Now, if I record and play a video with anroid it has this not acceptable latency. If I record and play with iPad it is almost no latency. But it is also good, if I record on android and receive on iPad. And it is also good, if I record on iPad and receive on android.
Playing on a PC, the iPad recorded (see here) is much better (and even mach smaller), than the android one (see here). But even the android recorded is (almost) acceptable. Really bad is, how the android ExoPlayer deals with the android recorded ones.
There can be differences in implementation of codecs of different players on any system which can be exaggerated on lower power devices. Have you tried using the native VideoView to play them on Android?
Yes, I can try VideoView, but I thought, that ExoPlayer is the better one. I am still searching, how to make the android record better. As you mentioned, even on other players, it is not good yet.
I haven't used the library so don't know what the options are, but possibly changing the audio codec or changing to a lower sample rate may help if it's available.
It would be much better to have this low level solution. Especially I was glad, that there is a almost similar one for B4i. But the recorded videos should be able to run on every standard player. So I will give a try the VideoRecordApp.
Part of the problem may be device specific, I tried recording with my Motorola G6 Play using the example you linked to in your first post and played it back using the default Android photo app. While not perfect, it was much better than the Android example video you posted.
Apple have control of the hardware that goes into their devices, so can generally provide a more consistent result, for newer devices at least..
It seems that for android I will find a solution, even if I have to choose VideoRecordApp instead of the prefered low level solution. Much more questions are now with the iOS version, I started a thread here. My tests with small videos where so successful, that I promised my music colleagues a new teaching platform on the end of the week. Now, in praxis with longer videos it becomes more complicated. Everything works fine, only the recording part is the big problem, in the moment.