CamcorderProfile cpVGA = CamcorderProfile.GetAll(cameraId, CamcorderQuality.Qvga);
this does not get resolved because the cameraId that I generated is a string and not Java.Lang.String...
Referring to this official documentation [getAll](https://developer.android.com/reference/android/media/CamcorderProfile#getAll(java.lang.String,%20int\)), we could find that the following tips:
String: the id for the camera. Numeric camera ids from the list received by invoking CameraManager#getCameraIdList can be used as long as they are CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE and not EXTERNAL. This value cannot be null.
Therefore, we could use string cameraId = manager.GetCameraIdList()[0];
to get the cameraId.
If you remove the part of the profile and use API29, just using mediaRecorder.SetVideoSize(1280, 720);
for recording, would the error occur?
that is how I already get cameraId however GetAll rejects it.
mediaRecorder.SetVideoSize(1280, 720) does execute but without any difference.
what I am expecting that for a 10M video file the time duration will increase as resolution decreases???
Did you use HasProfile method for checking whether your camcorder supported the quality?
Returns true if a camcorder profile exists for the first back-facing camera at the given quality level.
Did you use android.hardware.camera
in your project?
Referring to this documentation Camera, we could find that:
This class was deprecated in API level 21.
We recommend using the new API for new applications.android.hardware.camera2.
I am using the Camera2VideoFragment so its not the Camera API. In the openCamera method
cameraId = manager.GetCameraIdList()[0];
this gives a string that I use in GetAll which is rejected by the compiler. I am not sure how to convert string to Java string???? I am not sure that I am on the right path???
Did you use the sample repo https://github.com/xamarin/monodroid-samples/tree/main/android5.0/Camera2VideoSample?
If so, I've tested the sample and make it usable.
You could modify your mediarecoder part as the following code:
mediaRecorder.SetAudioSource (AudioSource.Mic);
mediaRecorder.SetVideoSource (VideoSource.Surface);
mediaRecorder.SetProfile(CamcorderProfile.Get(CamcorderQuality.Q720p));
mediaRecorder.SetOutputFile(GetVideoFile(Activity).AbsolutePath);
int rotation = (int)Activity.WindowManager.DefaultDisplay.Rotation;
int orientation = ORIENTATIONS.Get (rotation);
mediaRecorder.SetOrientationHint (orientation);
mediaRecorder.Prepare ();
ABSOLUTELY GENIUS!!!!! Brilliantly simple yet EXTREMELY OBJECTIVE!!!!!
I think this was superseding the quality used in earlier attempts
mediaRecorder.SetOutputFormat(OutputFormat.Mpeg4);
I will test this further. I am not sure how to mark your answer as the solution to the question. If you can please mark it as ANSWER.
Thank You
Sorry I don't know how to mark your Post as ANSWER...could you please tell me how to do it or if you can mark it as Answer Please do so!!!!
You solution is...
ABSOLUTELY GENIUS!!!!! Brilliantly simple yet EXTREMELY OBJECTIVE!!!!!
I think this was superseding the quality used in earlier attempts
mediaRecorder.SetOutputFormat(OutputFormat.Mpeg4);
I will test this further. I am not sure how to mark your answer as the solution to the question. If you can please mark it as ANSWER.
Thank You
Hello,
Did you use the sample repo https://github.com/xamarin/monodroid-samples/tree/main/android5.0/Camera2VideoSample?
If so, I've tested the sample and make it usable.
You could modify your mediarecoder part as the following code:
mediaRecorder.SetAudioSource (AudioSource.Mic);
mediaRecorder.SetVideoSource (VideoSource.Surface);
mediaRecorder.SetProfile(CamcorderProfile.Get(CamcorderQuality.Q720p));
mediaRecorder.SetOutputFile(GetVideoFile(Activity).AbsolutePath);
int rotation = (int)Activity.WindowManager.DefaultDisplay.Rotation;
int orientation = ORIENTATIONS.Get (rotation);
mediaRecorder.SetOrientationHint (orientation);
mediaRecorder.Prepare ();
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.