RootEncoder
RootEncoder copied to clipboard
sample app rtmp stream contains buffered video before clicking Start Stream button
Describe the bug After starting rtmp stream we see unwanted old video
To Reproduce Steps to reproduce the behavior:
- Go to Custom RTMP
- Enter rtmp Url
- move camera for 5 seconds, then toggle camera
- Click on Start stream
- On rtmp server we see video that was done before toggling camera and so on
Expected behavior May be clear buffer before start streaming
Screenshots If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
- Library version 2.3.1
- Device: Xiaomi Note 8 pro
- OS: Android 10
Additional context Add any other context about the problem here.
Hello,
I already clear the stream buffer before start stream in all protocols: https://github.com/pedroSG94/RootEncoder/blob/6f98f00a73e2f5604859bbc317ec9c8b349a541e/rtmp/src/main/java/com/pedro/rtmp/rtmp/RtmpSender.kt#L132
That is the line that clear the buffer queue when the stream start in rtmp module version 2.3.1. Also, you can clear the queue manually using this method if you need it:
rtmpCamera1.getStreamClient().clearCache();
Are you sure that it is not a problem in server/player side? You can test it using this server: https://github.com/bluenviron/mediamtx And VLC player for example.
Also, I recommend you use OpenGl example (OpenGlView instead of SurfaceView) if you don't need support API 16,17 because you can get better performance this way.
I will check it anyway to make sure
I tested using custom rtmp activity but I'm not able to reproduce it. I checked the queue size after call queue.clear and it is working as expected. Also, you can't create packets before start stream because it is ignored using running variable in that class: https://github.com/pedroSG94/RootEncoder/blob/6f98f00a73e2f5604859bbc317ec9c8b349a541e/rtmp/src/main/java/com/pedro/rtmp/rtmp/RtmpSender.kt#L106 https://github.com/pedroSG94/RootEncoder/blob/6f98f00a73e2f5604859bbc317ec9c8b349a541e/rtmp/src/main/java/com/pedro/rtmp/rtmp/RtmpSender.kt#L120
I'm not sure the way you are doing this tests but I'm not able to reproduce it. If possible try to send stream to different endpoints each time (replace stream name and application name in the endpoint if possible) to make sure that it is not related with the old stream cached by your server or player.
thank you for immediate answer, I will double check again and keep you in touch
Closing as inactive.