Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video recording fails to save to file #97

Closed
yonathan06 opened this issue Jan 5, 2019 · 12 comments
Closed

Video recording fails to save to file #97

yonathan06 opened this issue Jan 5, 2019 · 12 comments

Comments

@yonathan06
Copy link

stopVideoRecording() always returns false, with no error

  private var tmpVideoFile: File? = null

  @SuppressLint("SimpleDateFormat")
  @Throws(IOException::class)
  private fun getNewVideoFile(): File {
    // Create an image file name
    val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date())
    val directory = "${Environment.getExternalStorageDirectory().absolutePath}/filmit/videos".also { File(it).mkdirs() }
    return File(directory, "$timeStamp.mp4")
  }

  @SuppressLint("MissingPermission")
  private fun listenToVideoRecordEvent() {
    publisherDisposable = videoRecordEventPublisher.subscribe {
      if (it) {
        recordVideoFrame.visibility = View.VISIBLE
        tmpVideoFile = getNewVideoFile()
        recordVideoCamera.startVideoRecording(tmpVideoFile!!) {
          // Configure video (MediaRecorder) parameters
          audioEncoder = AudioEncoder.Aac
          videoFrameRate = 60
          videoStabilization = true
          videoEncoder = VideoEncoder.H263
        }
      } else {
        if(recordVideoCamera.stopVideoRecording()) {
          uploadTmpVideo()
        } else {
          Log.e(TAG, "failed to save video to file")
          Log.d(TAG, tmpVideoFile.toString())
        }
        recordVideoFrame.visibility = View.GONE
      }
    }

  }
@pvasa
Copy link
Owner

pvasa commented Jan 5, 2019

Have you registered an error listener? All the errors are thrown to error listeners which can be registered as below

CameraView.addCameraErrorListener { t: Throwable, errorLevel: ErrorLevel -> /* Camera error! */ }

Nothing can be implied from the information you provided above. Please reopen the issue when you have more information.

@pvasa pvasa closed this as completed Jan 5, 2019
@yonathan06
Copy link
Author

I added the error listener, but it is never called (although the stopVideoRecording is still returning false)
any idea why?
any way to see all of CameraView logs?

@yonathan06
Copy link
Author

in logcat it gives me a lot of these: E/mm-camera: <STATS_AEC ><ERROR> 1849: aec_process_calc_current_hist_metered_luma: error: out of range, exit

@pvasa
Copy link
Owner

pvasa commented Jan 6, 2019

Interesting, can you update the library to version 2.6.1 and use CameraView.isVideoRecording parameter to see if the recording is actually started? Also provide some more information about the device and OS you are using.

Also one more thing, are you setting the cameraMode to video_capture from view xml or you do it programmatically after the view is initialized?

@pvasa pvasa reopened this Jan 6, 2019
@yonathan06
Copy link
Author

yonathan06 commented Jan 7, 2019

updated and isVideoRecording is false before calling stopVideoRecording
also saw that the interface of addCameraErrorListener has changed, but still no error
I'm setting cameraMode to Modes.CameraMode.VIDEO_CAPTURE programmatically

I tried with the other way (setting it through the xml), but everything is the same

I'm running it on xiaomi mi 5 (android 8.0, API 26)

Maybe this is because the lib is using Timber? Saw there are not logs when I use Timber instead of Log

@pvasa
Copy link
Owner

pvasa commented Jan 9, 2019

Lib using Timber does not change anything. Try logging or throwing the throwable that you get in camera error listener. Something like,

cameraView.addCameraErrorListener { t: Throwable, errorLevel: ErrorLevel ->
    Log.d(TAG, "Camera error", t) // If you are using Log api
    throw t
}

@prajapatiravi257
Copy link

No error is thrown even after logging

@pvasa
Copy link
Owner

pvasa commented Jan 11, 2019

@prajapatiravi257 are you using the same device as @yonathan06? If not what device are you on? If yes have you tested on other devices? This issue could be very specific to certain devices. Also try running the sampleApp on same device and see if you are still seeing same problem.

@prajapatiravi257
Copy link

Yes even i have the same vendor model xiaomi 6A, I had also tested it on moto g5s plus and its working fine. And yes i am same issue with the sample app in xiaomi device.
Also even setting camera facing to front doesn't work.

@keremkusmezer
Copy link

Can it be that the device is mapped as Camera1 because of the capabilities check?

@prajapatiravi257
Copy link

yeah it can be but now i am using camera2 api from google samples for video recording and its working fine

@pvasa pvasa closed this as completed Jan 13, 2019
@pvasa pvasa reopened this Jan 13, 2019
@pvasa
Copy link
Owner

pvasa commented Jan 16, 2019

It seems, on certain devices, the library is falling back to camera1 implementation and thus could not start video recording (not supported on camera1). Implementing video recording on camera1 might be a future enhancement. In regards with this issue, the library functions as designed.

@pvasa pvasa closed this as completed Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants