You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am getting following exception while start camera. and my goal is to capture video and continues frames.
Please help me to solve this issue.
com.priyankvasa.android.cameraviewex.CameraViewException: Unable to start video recording.
java.lang.ArithmeticException: divide by zero
Unable to start video recording.
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// Callbacks on UI thread
_binding?.camera?.addCameraOpenedListener { /* Camera opened. */ }
?.addCameraErrorListener { t: Throwable, errorLevel: ErrorLevel -> /* Camera error! */
Log.d("AAAAAA ", "addCameraErrorListener")
}
?.addCameraClosedListener { /* Camera closed. */
Log.d("AAAAAA ", "addCameraClosedListener")
}
}
override fun onResume() {
super.onResume()
if (ActivityCompat.checkSelfPermission(
requireContext(),
Manifest.permission.CAMERA
) != PackageManager.PERMISSION_GRANTED
) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return
}
_binding?.camera?.start(Modes.DEFAULT_CAMERA_ID)
// _binding?.camera?.setCameraMode(Modes.CameraMode.SINGLE_CAPTURE or Modes.CameraMode.CONTINUOUS_FRAME or Modes.CameraMode.VIDEO_CAPTURE)
// _binding?.camera?.setCameraMode(Modes.CameraMode.VIDEO_CAPTURE)
// OR keep other modes as is and enable video capture mode
// _binding?.camera?.enableCameraMode(Modes.CameraMode.VIDEO_CAPTURE)
// Callback on UI thread
_binding?.camera?.addVideoRecordStartedListener { /* Video recording started */
Log.d("AAAAAA ", "Video recording started")
}
// Callback on UI thread
_binding?.camera?.addVideoRecordStoppedListener { isSuccess ->
// Video recording stopped
Log.d("AAAAAA ", "Video recording stopped")
// isSuccess is true if video was recorded and saved successfully
}
_binding?.camera?.setContinuousFrameListener {
Log.d("AAAAAA ", "Continuous Frame Listener")
showFramePreview(it)
}
val direct = File(Environment.getExternalStorageDirectory().toString() + "/capture_video")
if (!direct.exists()) {
val wallpaperDirectory = File("/sdcard/capture_video/")
wallpaperDirectory.mkdirs()
}
val file = File("/sdcard/capture_video/", "video_" + System.currentTimeMillis() + ".mp4")
if (file.exists()) {
file.delete()
}
_binding?.camera?.startVideoRecording(file) {
// Configure video (MediaRecorder) parameters
audioEncoder = AudioEncoder.Aac
videoFrameRate = 30
videoStabilization = true
}
}
The text was updated successfully, but these errors were encountered:
Hi,
I am getting following exception while start camera. and my goal is to capture video and continues frames.
Please help me to solve this issue.
com.priyankvasa.android.cameraviewex.CameraViewException: Unable to start video recording.
java.lang.ArithmeticException: divide by zero
Unable to start video recording.
My code is --
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// _binding?.camera?.setCameraMode(Modes.CameraMode.SINGLE_CAPTURE or Modes.CameraMode.CONTINUOUS_FRAME or Modes.CameraMode.VIDEO_CAPTURE)
// _binding?.camera?.setCameraMode(Modes.CameraMode.VIDEO_CAPTURE)
// OR keep other modes as is and enable video capture mode
// _binding?.camera?.enableCameraMode(Modes.CameraMode.VIDEO_CAPTURE)
// Callback on UI thread
_binding?.camera?.addVideoRecordStartedListener { /* Video recording started */
Log.d("AAAAAA ", "Video recording started")
}
// Callback on UI thread
_binding?.camera?.addVideoRecordStoppedListener { isSuccess ->
// Video recording stopped
Log.d("AAAAAA ", "Video recording stopped")
// isSuccess is true if video was recorded and saved successfully
}
The text was updated successfully, but these errors were encountered: