begeekmyfriend / yasea

RTMP live streaming client for Android
MIT License
4.87k stars 1.32k forks source link

how to reduce the stream delay ? #325

Open Doss12 opened 7 years ago

begeekmyfriend commented 7 years ago

The first point of you need to care about this problem is the bandwidth between your application and the RTMP server. The approach is to use FFmpeg to make comparision with the same server and player.

ffmpeg -re -i test.mp4 -vcodec libx264 -acodec copy -f flv rtmp://host:1935/live/streamname

If it seems as bad as Yasea, what you need to do is check of your server and inquiry of your ISP.

If it works well, then I would like to ask you a question in advance -- what are you going to apply yasea to do and what did you do in the modification porting of yasea.

I have contacted many users who apply yasea far from the original application of mobile phone streaming such as Android TV, surveillance cameras, drones and so on. There are different peripherals in different areas and therefore may well produce different effect. In the view of streaming end, the less for the buffer, the less for the delay.

By the way, the latest version of yasea is v2.4.1.

begeekmyfriend commented 7 years ago

By the way, did you use multi-threading for getting raw data and sending it into the encoder? Single thread may block the whole process and result in lag.

begeekmyfriend commented 7 years ago

One more thing, you may try to reduce the bit rate of video stream for less lag. Change setVideoHDMode into setVideoSmoothMode in MainActivity.java

Doss12 commented 7 years ago

We have changed the buffer size,vgop and the vfps, the delay was reduced from 15 seconds to 7 seconds and we're satisfied with the result,thank you very much for your help

Doss12 commented 7 years ago

private byte[] mPcmBuffer = new byte[2048]; VGOP =18 VFPS = 32

begeekmyfriend commented 7 years ago

I see, you want to generate one I-frame within one second.