RootEncoder icon indicating copy to clipboard operation
RootEncoder copied to clipboard

Can I show realtime bitrate, resolution, fps on the screen?

Open wsw2435 opened this issue 7 years ago • 6 comments

When I start the stream, can I show real-time bitrate, resolution, fps on the screen? Is there any method for showing those information on a new created text view?

wsw2435 avatar Jul 09 '19 03:07 wsw2435

Yes, you can. Note: This will work while stream or record but no in preview.

  • Resolution:
Log.e("Pedro", rtmpCamera1.getStreamWidth() + "x" + rtmpCamera1.getStreamHeight());
  • Bitrate: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/wiki/Adaptative-video-bitrate. Use adaptative bitrate example and delete "AdapterBitrateParser". In onBandwidthStateChange(double bandwidth) callback you will get the bitrate used.

  • FPS: Use the last commit of the project (This feature is not in gradle yet)

rtmpCamera1.setFpsListener(new FpsListener.Callback() {

      @Override
      public void onFps(int fps) {
        Log.e("Pedro", "" + fps);
      }
    });

If you dont know how to compile project manually you can follow this: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/wiki/Add-library-to-your-project

pedroSG94 avatar Jul 09 '19 11:07 pedroSG94

Yes, you can. Note: This will work while stream or record but no in preview.

  • Resolution:
Log.e("Pedro", rtmpCamera1.getStreamWidth() + "x" + rtmpCamera1.getStreamHeight());
  • Bitrate: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/wiki/Adaptative-video-bitrate. Use adaptative bitrate example and delete "AdapterBitrateParser". In onBandwidthStateChange(double bandwidth) callback you will get the bitrate used.
  • FPS: Use the last commit of the project (This feature is not in gradle yet)
rtmpCamera1.setFpsListener(new FpsListener.Callback() {

      @Override
      public void onFps(int fps) {
        Log.e("Pedro", "" + fps);
      }
    });

If you dont know how to compile project manually you can follow this: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/wiki/Add-library-to-your-project

For those information, how could I pass them into a text view?

wsw2435 avatar Jul 09 '19 12:07 wsw2435

You can create 3 global variables in class and concatenate all values in a string. Then, you can update textivew text every second for example.

pedroSG94 avatar Jul 09 '19 12:07 pedroSG94

Dear pedro, for the bitrate one, I applied the whole code for camera1. is this bitrate an available bitrate, or a actual stream bitrate, or a bandwidth bitrate? Since i tested with 360p stream, supposes ~2.5mbps is enough for the stream, but in 20 second , the text showed from 3mbps to 12mbps. It is strange to me, could you give me an advice? Thank you so much.

P.s.when i see the monitor on my server, the stream-in bitrate is around 2-3mbps, not 11mbps like the text showed.

wsw2435 avatar Jul 09 '19 14:07 wsw2435

The bitrate is calculated with the upload bandwith of your device so maybe this is not totally real because other app can be using it in background. Anyway I found a best way to calculate bitrate usage so I will change it soon

pedroSG94 avatar Jul 10 '19 08:07 pedroSG94

I did a callback to know the bitrate: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/app/src/main/java/com/pedro/rtpstreamer/defaultexample/ExampleRtmpActivity.java#L90

pedroSG94 avatar Jul 10 '19 12:07 pedroSG94