pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.57k stars 776 forks source link

SurfaceModeRTMPActivity &OpenGLRtmpActivity #188

Closed camillocam closed 5 years ago

camillocam commented 6 years ago

Hello, I try your example code with my huawei P9 lite . The default example is OK good work, but i try SurfaceModeRTMP when the connection success the video freez but the audio is streaming. OpenGLR the video ok but the server receive only audio. The log in Android Studio is E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null

Can you help me?

camillocam commented 6 years ago

E/Legacy-CameraDevice-JNI: LegacyCameraDevice_nativeDetectSurfaceDimens: Error while querying surface width No such device (-19). E/AndroidRuntime: FATAL EXCEPTION: Camera2ApiManager Id = 0 Process: com.pedro.rtpstreamer, PID: 5857 java.lang.IllegalArgumentException: Surface was abandoned at android.hardware.camera2.utils.SurfaceUtils.getSurfaceSize(SurfaceUtils.java:70) at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:184) at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:94) at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:489) at com.pedro.encoder.input.video.Camera2ApiManager.startPreview(Camera2ApiManager.java:108) at com.pedro.encoder.input.video.Camera2ApiManager.onOpened(Camera2ApiManager.java:342) at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:134) at android.os.Handler.handleCallback(Handler.java:761) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:156) at android.os.HandlerThread.run(HandlerThread.java:61) Caused by: android.hardware.camera2.legacy.LegacyExceptionUtils$BufferQueueAbandonedException at android.hardware.camera2.legacy.LegacyExceptionUtils.throwOnError(LegacyExceptionUtils.java:73) at android.hardware.camera2.legacy.LegacyCameraDevice.getSurfaceSize(LegacyCameraDevice.java:585) at android.hardware.camera2.utils.SurfaceUtils.getSurfaceSize(SurfaceUtils.java:68) at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:184)  at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:94)  at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:489)  at com.pedro.encoder.input.video.Camera2ApiManager.startPreview(Camera2ApiManager.java:108)  at com.pedro.encoder.input.video.Camera2ApiManager.onOpened(Camera2ApiManager.java:342)  at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:134)  at android.os.Handler.handleCallback(Handler.java:761)  at android.os.Handler.dispatchMessage(Handler.java:98)  at android.os.Looper.loop(Looper.java:156)  at android.os.HandlerThread.run(HandlerThread.java:61) 

pedroSG94 commented 6 years ago

This look that your device no support full Camera2 API Did you see preview before start stream? If yes, maybe the problem is that your device can't render 2 surface at time with camera2 (You do it when you use surfaceview or textureview. You are rendering preview surface and encoder surface). Try replace surfaceview to lightopenglview or openglview that only need render one surface at time.

OpenGLR is OpenglRTMP example? Can you post me logcat of that activity? (connection and few seconds of stream)

camillocam commented 6 years ago

07-05 19:09:06.652 7740-7740/com.pedro.rtpstreamer I/MicrophoneManager: Microphone created, 44100hz, Stereo 07-05 19:09:06.653 7740-7740/com.pedro.rtpstreamer I/MicrophoneManager: Microphone created, 44100hz, Stereo 07-05 19:09:06.658 7740-7946/com.pedro.rtpstreamer I/OMXClient: MuxOMX ctor 07-05 19:09:06.671 7740-7946/com.pedro.rtpstreamer I/ACodec: In onAllocateComponent create compenent, codec name: OMX.google.aac.encoder 07-05 19:09:06.933 7740-7753/com.pedro.rtpstreamer I/CameraDevice-JV-0: Camera now idle 07-05 19:09:06.956 7740-7740/com.pedro.rtpstreamer W/VideoCapabilities: Unrecognized profile/level 1/32 for video/mp4v-es 07-05 19:09:06.956 7740-7740/com.pedro.rtpstreamer I/VideoCapabilities: Unsupported profile 16384 for video/mp4v-es Unsupported profile 16384 for video/mp4v-es 07-05 19:09:06.961 7740-7740/com.pedro.rtpstreamer W/VideoCapabilities: Unsupported mime video/x-pn-realvideo 07-05 19:09:06.963 7740-7740/com.pedro.rtpstreamer W/VideoCapabilities: Unsupported mime video/mpeg 07-05 19:09:06.964 7740-7740/com.pedro.rtpstreamer W/VideoCapabilities: Unrecognized profile/level 0/0 for video/mpeg2 Unrecognized profile/level 0/2 for video/mpeg2 Unrecognized profile/level 0/3 for video/mpeg2 07-05 19:09:06.966 7740-7740/com.pedro.rtpstreamer W/VideoCapabilities: Unrecognized profile/level 32768/2 for video/mp4v-es 07-05 19:09:06.969 7740-7740/com.pedro.rtpstreamer W/VideoCapabilities: Unsupported mime video/vc1 07-05 19:09:06.972 7740-7740/com.pedro.rtpstreamer W/VideoCapabilities: Unsupported mime video/x-flv 07-05 19:09:06.990 7740-7740/com.pedro.rtpstreamer I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es 07-05 19:09:06.994 7740-7740/com.pedro.rtpstreamer I/VideoEncoder: VideoEncoder OMX.IMG.TOPAZ.VIDEO.Encoder 07-05 19:09:06.995 7740-7740/com.pedro.rtpstreamer I/VideoEncoder: Color supported: 2130706433 07-05 19:09:06.996 7740-7740/com.pedro.rtpstreamer I/VideoEncoder: Color supported: 2135033992 Color supported: 20 07-05 19:09:07.007 7740-7952/com.pedro.rtpstreamer I/OMXClient: MuxOMX ctor 07-05 19:09:07.014 7740-7952/com.pedro.rtpstreamer I/ACodec: In onAllocateComponent create compenent, codec name: OMX.IMG.TOPAZ.VIDEO.Encoder 07-05 19:09:07.015 7740-7740/com.pedro.rtpstreamer I/VideoEncoder: Prepare video info: SURFACE, 640x480 07-05 19:09:07.016 7740-7952/com.pedro.rtpstreamer I/HwExtendedCodec: error setConfig HisiTimestampCalculate (err -1010) 07-05 19:09:07.017 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000001 = 2130706433 07-05 19:09:07.019 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000005 = 2130706437 07-05 19:09:07.019 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000002 = 2130706434 07-05 19:09:07.020 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000006 = 2130706438 07-05 19:09:07.020 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x17 = 23 07-05 19:09:07.021 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x18 = 24 07-05 19:09:07.021 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000011 = 2130706449 07-05 19:09:07.021 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x16 = 22 07-05 19:09:07.022 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000007 = 2130706439 07-05 19:09:07.022 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000008 = 2130706440 07-05 19:09:07.023 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x19 = 25 07-05 19:09:07.023 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x1a = 26 07-05 19:09:07.023 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x1b = 27 07-05 19:09:07.024 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x1c = 28 07-05 19:09:07.024 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000003 = 2130706435 07-05 19:09:07.024 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000009 = 2130706441 07-05 19:09:07.025 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f00000c = 2130706444 07-05 19:09:07.025 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000012 = 2130706450 07-05 19:09:07.025 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f00000a = 2130706442 07-05 19:09:07.026 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f00000b = 2130706443 07-05 19:09:07.026 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000789 = 2130708361 07-05 19:09:07.027 7740-7952/com.pedro.rtpstreamer I/ACodec: setupAVCEncoderParameters with [profile: Baseline] [level: Level52] [OMX.IMG.TOPAZ.VIDEO.Encoder] cannot encode color aspects. Ignoring. [OMX.IMG.TOPAZ.VIDEO.Encoder] cannot encode HDR static metadata. Ignoring. setupVideoEncoder succeeded 07-05 19:09:07.028 7740-7952/com.pedro.rtpstreamer W/ACodec: do not know color format 0x7f000789 = 2130708361 07-05 19:09:07.079 7740-7958/com.pedro.rtpstreamer I/SrsFlvMuxer: worker: connecting to RTMP server by url=rtmp://192.168.1.55:1935/live/stream 07-05 19:09:07.104 7740-7740/com.pedro.rtpstreamer I/AudioEncoder: AudioEncoder started 07-05 19:09:07.117 7740-7740/com.pedro.rtpstreamer I/AudioRecordPermission: remindWithResult:false 07-05 19:09:07.117 7740-7740/com.pedro.rtpstreamer I/HwAudioRecordImpl: HwAudioRecordImpl checkRecordActive 07-05 19:09:07.134 7740-7740/com.pedro.rtpstreamer I/HwAudioRecordImpl: sendStateChangedIntent, state=3 07-05 19:09:07.138 7740-7740/com.pedro.rtpstreamer I/MicrophoneManager: Microphone started 07-05 19:09:07.156 7740-7740/com.pedro.rtpstreamer I/Choreographer: Skipped 31 frames! The application may be doing too much work on its main thread. 07-05 19:09:07.160 7740-7963/com.pedro.rtpstreamer I/RtmpConnection: handleRxInvoke: Got result for invoked method: connect 07-05 19:09:07.168 7740-7965/com.pedro.rtpstreamer I/Camera2ApiManager: camera opened 07-05 19:09:07.172 7740-7965/com.pedro.rtpstreamer I/Camera2ApiManager: camera configured 07-05 19:09:07.208 7740-7963/com.pedro.rtpstreamer I/RtmpConnection: handleRxInvoke: Got result for invoked method: createStream 07-05 19:09:07.217 7740-7740/com.pedro.rtpstreamer E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 07-05 19:09:07.229 7740-7740/com.pedro.rtpstreamer E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 07-05 19:09:07.236 7740-7740/com.pedro.rtpstreamer I/HwPointEventFilter: do not support AFT because of no config 07-05 19:09:16.728 7740-7740/com.pedro.rtpstreamer I/SrsFlvMuxer: SrsFlvMuxer closed 07-05 19:09:16.731 7740-9795/com.pedro.rtpstreamer I/SrsFlvMuxer: worker: disconnect ok. 07-05 19:09:16.780 7740-7740/com.pedro.rtpstreamer I/HwAudioRecordImpl: sendStateChangedIntent, state=1 07-05 19:09:16.782 7740-7740/com.pedro.rtpstreamer I/HwAudioRecordImpl: sendStateChangedIntent, state=1 07-05 19:09:16.784 7740-7740/com.pedro.rtpstreamer I/MicrophoneManager: Microphone stopped 07-05 19:09:16.828 7740-7740/com.pedro.rtpstreamer I/AudioEncoder: AudioEncoder stopped 07-05 19:09:16.836 7740-7740/com.pedro.rtpstreamer E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 07-05 19:09:16.839 7740-7740/com.pedro.rtpstreamer E/HW-JPEG-DEC: HME_JPEG_DEC_Delete: HME_JPEG_DEC_Delete: decoder_ctx=null 07-05 19:09:16.847 7740-7740/com.pedro.rtpstreamer I/HwPointEventFilter: do not support AFT because of no config

camillocam commented 6 years ago

This LogCat is with Surface MODE RTMP

camillocam commented 6 years ago

"Did you see preview before start stream?" When i push on Start Stream the preview block, and send only audio to server.

pedroSG94 commented 6 years ago

Maybe the problem is reopen camera. Try delete this line in the example (with this you will open camera directly when you call startStream method): https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/app/src/main/java/com/pedro/rtpstreamer/surfacemodeexample/SurfaceModeRtmpActivity.java#L190

If the problem persist replace surfaceview to lightopenglview and try. If it still no work, maybe you can change camera configuration in this class: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/encoder/src/main/java/com/pedro/encoder/input/video/Camera2ApiManager.java If you find some configuration that work for you let me know it because I can't reproduce your case with my device. If I find a device with a similar problem I will try find the cause and notify you.

camillocam commented 6 years ago

The problem is device, because i change device and it's work, The huawei p9 light have problem with Camera2.

camillocam commented 6 years ago

I try example for create video with camera2 and the screen is block on first image.

pedroSG94 commented 6 years ago

Google example block? If the problem is device, nothing to do. Anyway I will try find some info about this error with that device in internet. Maybe work with some specific configuration.