RootEncoder icon indicating copy to clipboard operation
RootEncoder copied to clipboard

Crash This camera resolution cant be opened

Open digitalStyx opened this issue 8 years ago • 4 comments

Hi

I have some crash: Fatal Exception: com.pedro.encoder.input.video.CameraOpenException: This camera resolution cant be opened at com.pedro.encoder.input.video.a$1.run(SourceFile:130) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:227) at android.os.HandlerThread.run(HandlerThread.java:61)

When I start streaming I do exactly as in your example app. I read resolutions from rtmpCamera1.getResolutions() and choose last from this list and pass to prepareVideo.

In Fabric I see that problem is affect to:

  • HTC One A9s (Android 6.0)
  • Wiko Robby (Android 6.0)
  • Galaxy J5(2016) (Android 6.0)

But I have application deployment with your library(1.2.4) at the level of 10% yet.

What can be problem?

In the past I used https://github.com/fyhertz/libstreaming, and sometimes was problem during changing camera. Front and Back Camera had different resolution and If I use ex. 640x480 for front i can't use it for back.

It is possible in your library? If I use rtmpCamera1.switchCamera() this problem is solve?

digitalStyx avatar Dec 04 '17 13:12 digitalStyx

You can see a example in custom activity to switch camera. You need capture exception because front camera and back camera could not has same resolutions.

try {
          rtmpCamera1.switchCamera();
        } catch (CameraOpenException e) {
          Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
          rtmpCamera1.switchCamera();
        }

https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/app/src/main/java/com/pedro/rtmpstreamer/customexample/RtmpActivity.java#L287

pedroSG94 avatar Dec 04 '17 14:12 pedroSG94

I have this code, but I think it doesn't work, because CameraOpenException is throw in another thread.

Look https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/encoder/src/main/java/com/pedro/encoder/input/video/Camera1ApiManager.java#L130 is in thread.post(new Runnable() { and you can't catch exception from application. Am I right?

digitalStyx avatar Dec 04 '17 14:12 digitalStyx

Yes, you are right. I'm fixing. https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/commit/20781137e9a3401fe7f404775c1c70de15a803ec Broke it.

pedroSG94 avatar Dec 04 '17 18:12 pedroSG94

Fixed in version 1.2.5. Now method getResolutions() was renamed to getResolutionsBack(). Also you have getResolutionsFront() if you want get resolutions of your front camera. Delete switch line in catch. This is now unnecessary (if you don't do it, app will crash): https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/commit/b5f39ebcfd6ffa54556b8aa35a2980036f22bb10#diff-0c7e686756a9984626638beb7c2358d1L300

pedroSG94 avatar Dec 04 '17 18:12 pedroSG94