LibRtmp-Client-for-Android
LibRtmp-Client-for-Android copied to clipboard
Buffer size is not controllable
Buffer size is better to be controllable from Java (through RtmpClient).
I see,
A quick solution, have you you realized that there is a buffer parameter that you can give at the url.
https://rtmpdump.mplayerhq.hu/librtmp.3.html
buffer=num Set buffer time to num milliseconds. The default is 30000.
I know. But it's option of librtmp itself.
https://github.com/ant-media/LibRtmp-Client-for-Android/blob/master/rtmp-client/src/main/cpp/librtmp/rtmp.c
has I/F RTMP_SetBufferMS
, but it's not jni exported
https://github.com/ant-media/LibRtmp-Client-for-Android/blob/master/rtmp-client/src/main/cpp/librtmp-jni.c
yes you're right.
Do you need this kind of implementation urgently? In other hands, when do you need?
On the other hand, if you have chance to make a PR, I will be glad to merge it.
If possibble, I want to use RTMP playback feature through ExoPlayer, but for live streaming service, latency is very important thing. Now, the latency of RTMP on ExoPlayer is larger than that of HLS.
Sorry for the late reply.
There should be a problem in somewhere, because latency does not exceed 3 seconds in our tests.
Which server do you use?
Regards,
latency does not exceed 3 seconds in our tests
It may depend on the definition of "latency". I mean the time between "Broadcaster do something in front of camera" and "it's displayed on screen of viewer", and our target of this "latency" is about 2-4 secs. 3 secs buffer size on librtmp is too large for us.
When I use ExoPlayer(with default setting) with RTMP extension (which use this library), it's about 3-8 seconds slower than our RTMP player for iOS. The video is come from same broadcaster/server. I think buffer size of librtmp (3 seconds) is one of the reason. Additionally, ExoPlayer may have their own buffer.
Yeah we both mean the samething for latency.
Let us check the latency one more time and post here.
Do we have plant to add this feature?
Any news on this? I am having the same issue with Exoplayer. @mekya
Did you find a solution? @matsujun
this buffer time actually does not affect latency in RTMP. We have made some tests for @nagendraK6 :) and find out somethings. I have copied-pasted the things directly from email :)
Hey Guys,
Let me tell what I have found.
Firstly, I digged into the native librtmp to find out somethings to reduce buffering times. Yeah I have found somethings, max buffer time for librtmp is 30sec.
I have changed it several times, compiled native code and test it unfourtunately there is nothing changed. After all i go deeper and found out that librtmp does not care about this buffering time. It just reads data from server.
After that I've started to look at the buffering times for ExoPlayer. After a while I found, min buffer, max buffer, play back buffer, playback rebuffer durations.
I have changed these default values by creating ExoPlayer like below
player = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector, new DefaultLoadControl(
new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE),
500, // min buffer 0.5s
3000, //max buffer 3s
1000, // playback 1s
1000 //playback after rebuffer 1s
));
Then latency is really good on our test environment about 1.5 - 2 and no rebufferings. Source stream has 2 sec key frame interval.
However we need to be sure it also works for your real environment.
The parameters above I've used needs to be tuned for your case. Values can be bigger or lower, just let's test on your environment and see the results.
Btw, health of the source stream is very important. If server does not has an healthy incoming stream, it is for sure that server does not send any stream to viewers and
rebufferings happen on viewer side.
Regards,
A. Oguz
hello i have the same problem, my rtmp stream has low latency when played with ffplay but with exo player there is an important delay (3/4 seconds) i tested your code : DefaultAllocator allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE); DefaultLoadControl loadControl = new DefaultLoadControl(allocator, 1000, 1000, 1000, 1000, -1, true); player = ExoPlayerFactory.newSimpleInstance(this, trackSelector,loadControl);
but not change ...
i tested to add the buffer option in my url but no improvement
videoSource = new ExtractorMediaSource.Factory(mediaDataSourceFactory) .createMediaSource( Uri.parse(url + " live=1 buffer=0"), null, null );
this is my command with ffplay ffplay -fflags nobuffer rtmp://xxx:1935/live/xxx -loglevel verbose