Closed dengpan-edgejumps closed 5 months ago
The RTMP connection was established correctly, and my local RTMP server could receive some data and indicate living.
However, the RTMP connection would be disconnected when writing buffer after seconds, and then my local RTMP server became idle and indicates not living.
The same error is also applied when I used api.video's RTMP server.
my guess is that 1) the buffer is overflowing the RTMP server 2) or the encoded data is malformed or contains errors
However, I have little knowledge about Kotlin and no idea about how to diagnose and fix it.
As far as I understand, you don't use rtmp://broadcast.api.video/s
but a local server. What local server do you use?
The error looks like an issue with the connection. Could you try to reduce video bitrate?
I'm seeing this error regularly with the rtmp://broadcast.api.video/s
endpoint, and the default settings in the demo app.
E/RtmpProducer(23985): java.net.SocketException: Connection error
E/RtmpProducer(23985): at video.api.rtmpdroid.Rtmp.write(Rtmp.kt:139)
E/RtmpProducer(23985): at io.github.thibaultbee.streampack.ext.rtmp.internal.endpoints.RtmpProducer.write(RtmpProducer.kt:94)
E/RtmpProducer(23985): at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$muxListener$1.onOutputFrame(BaseStreamer.kt:132)
E/RtmpProducer(23985): at io.github.thibaultbee.streampack.internal.muxers.flv.FlvMuxer.encode(FlvMuxer.kt:77)
E/RtmpProducer(23985): at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$videoEncoderListener$1.onOutputFrame(BaseStreamer.kt:120)
E/RtmpProducer(23985): at io.github.thibaultbee.streampack.internal.encoders.MediaCodecEncoder$encoderCallback$1.onOutputBufferAvailable(MediaCodecEncoder.kt:109)
E/RtmpProducer(23985): at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1943)
E/RtmpProducer(23985): at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1841)
E/RtmpProducer(23985): at android.os.Handler.dispatchMessage(Handler.java:106)
E/RtmpProducer(23985): at android.os.Looper.loopOnce(Looper.java:230)
E/RtmpProducer(23985): at android.os.Looper.loop(Looper.java:319)
E/RtmpProducer(23985): at android.os.HandlerThread.run(HandlerThread.java:67)
It seems that lowering the bitrate does help. I suggest that the demo app should set the demo bitrates to something lower, because it's a frustrating experience that the app doesn't work out-of-the-box.
@ndahlquist Thanks for the feedback. It is never easy to set such default parameter because one could expect a low bitrate and one could expect a better quality. Anyway, I lower the default resolution and (bitrate at the same time): https://github.com/apivideo/api.video-flutter-live-stream/commit/a6313cd8d5de510955218f2c87771ed2f5ea5721
So this issue seems to be related to the default video bitrate. I am closing it. Please reopen an issue if you still face it.
I too am getting this error, and have tried lowering the bitrate to RESOLUTION_240 in code, as well as trying all bitrate options in Settings of example app. The app runs fine and streams on Pixel 7a, so it's not a problem with app / network.
The device I'm testing on is a Chinese Android tablet device, so perhaps it's related to that, but is there a way we can troubleshoot?
I presume from the following error it's some encoding issue? E/RtmpProducer(16034): at io.github.thibaultbee.streampack.internal.muxers.flv.FlvMuxer.encode(FlvMuxer.kt:77)
Full error: E/rtmpdroid(16034): WriteN, RTMP send error 32 (111 bytes) E/rtmpdroid(16034): WriteN, RTMP send error 32 (71 bytes) E/rtmpdroid(16034): WriteN, RTMP send error 9 (42 bytes) E/RtmpProducer(16034): Error while writing packet to socket E/RtmpProducer(16034): java.net.SocketException: Connection error E/RtmpProducer(16034): at video.api.rtmpdroid.Rtmp.write(Rtmp.kt:139) E/RtmpProducer(16034): at io.github.thibaultbee.streampack.ext.rtmp.internal.endpoints.RtmpProducer.write(RtmpProducer.kt:94) E/RtmpProducer(16034): at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$muxListener$1.onOutputFrame(BaseStreamer.kt:132) E/RtmpProducer(16034): at io.github.thibaultbee.streampack.internal.muxers.flv.FlvMuxer.encode(FlvMuxer.kt:77) E/RtmpProducer(16034): at io.github.thibaultbee.streampack.streamers.bases.BaseStreamer$videoEncoderListener$1.onOutputFrame(BaseStreamer.kt:120) E/RtmpProducer(16034): at io.github.thibaultbee.streampack.internal.encoders.MediaCodecEncoder$encoderCallback$1.onOutputBufferAvailable(MediaCo decEncoder.kt:109) E/RtmpProducer(16034): at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1664) E/RtmpProducer(16034): at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1611) E/RtmpProducer(16034): at android.os.Handler.dispatchMessage(Handler.java:102) E/RtmpProducer(16034): at android.os.Looper.loop(Looper.java:154) E/RtmpProducer(16034): at android.os.HandlerThread.run(HandlerThread.java:61)
Version
v1.1.1
Which operating systems have you used?
Environment that reproduces the issue
Google Pixel 6 (Android 12)
Is it reproducible in the example application?
Yes
RTMP Server
rtmp://broadcast.api.video/s
Reproduction steps
VideoConfig.defaultBitrate()
AudioConfig()
startPreview()
startStreaming(streamKey)
Expected result
The RTMP server could receive the video stream correctly.
Actual result
startPreview()
works correctly because I could see the video on the preview widget, while the video stream seems not sent to the RTMP server correctly.The same error also applies to the
example
application, not just my application.It would first report
connected
event, and then this error was thrown. As a result, adisconnect
event was reported after seconds.Additional context
Relevant logs output
No response