RootEncoder icon indicating copy to clipboard operation
RootEncoder copied to clipboard

sample app rtmp stream contains buffered video before clicking Start Stream button

Open acris5 opened this issue 1 year ago • 3 comments

Describe the bug After starting rtmp stream we see unwanted old video

To Reproduce Steps to reproduce the behavior:

  1. Go to Custom RTMP
  2. Enter rtmp Url
  3. move camera for 5 seconds, then toggle camera
  4. Click on Start stream
  5. 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.

acris5 avatar Nov 17 '23 12:11 acris5

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

pedroSG94 avatar Nov 17 '23 13:11 pedroSG94

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.

pedroSG94 avatar Nov 17 '23 13:11 pedroSG94

thank you for immediate answer, I will double check again and keep you in touch

acris5 avatar Nov 17 '23 13:11 acris5

Closing as inactive.

pedroSG94 avatar Feb 26 '24 11:02 pedroSG94